Connected in GUI but cannot connect using script in batch file when using private key.
I connected successfully in winSCP GUI.
From the session I generated Session URL/Code that I saved as .bat file.
Here is the script:
@echo off
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\temp\WinSCP.log" /ini=nul ^
/command ^
"open sftp://myname@ftp.hostserver.com/ -hostkey=""ssh-dss 1024 OlabPXrXjhEHLUGj0Mh2AgwokSZhory81gKZTd/tQ/c="" -privatekey=""C:\FTP\test.ppk"" -passphrase=""MySecretKey"" -rawsettings ProxyPort=1" ^
"exit"
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)
exit /b %WINSCP_RESULT%
And here are the log lines:
From GUI:
...
. Server offered these authentication methods: password,publickey
. Prompt (password, "SSH password", <no instructions>, "&Password: ")
. Using stored password.
. Sent password
...
...
From Batch:
...
. Server offered these authentication methods: password,publickey
. Prompt (password, "SSH password", <no instructions>, "&Password: ")
. Disconnected: Unable to authenticate
Here I'm stuck.
From the session I generated Session URL/Code that I saved as .bat file.
Here is the script:
@echo off
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\temp\WinSCP.log" /ini=nul ^
/command ^
"open sftp://myname@ftp.hostserver.com/ -hostkey=""ssh-dss 1024 OlabPXrXjhEHLUGj0Mh2AgwokSZhory81gKZTd/tQ/c="" -privatekey=""C:\FTP\test.ppk"" -passphrase=""MySecretKey"" -rawsettings ProxyPort=1" ^
"exit"
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)
exit /b %WINSCP_RESULT%
And here are the log lines:
From GUI:
...
. Server offered these authentication methods: password,publickey
. Prompt (password, "SSH password", <no instructions>, "&Password: ")
. Using stored password.
. Sent password
...
...
From Batch:
...
. Server offered these authentication methods: password,publickey
. Prompt (password, "SSH password", <no instructions>, "&Password: ")
. Disconnected: Unable to authenticate
Here I'm stuck.