Connected in GUI but cannot connect using script in batch file when using private key.

Advertisement

graga
Joined:
Posts:
2
Location:
Australia

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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: Connected in GUI but cannot connect using script in batch file when using private key.

Please attach complete log files both from GUI and script.

Reply with quote

graga
Joined:
Posts:
2
Location:
Australia

I found the problem / solution.
When you save session into script, winSCP does not save the password.

The "open" commend in generated script was:
"open sftp://myname@ftp.hostserver.com/ -hostkey=""ssh-dss 1024

but should be:
"open sftp://myname:mypassword@ftp.hostserver.com/ -hostkey=""ssh-dss 1024

All is working now.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

graga wrote:

I found the problem / solution.
When you save session into script, winSCP does not save the password.
It does. As long as you have the password saved into the your site.

I didn't expect you need a password, as you have a private key specified in your script.

Reply with quote

Advertisement

You can post new topics in this forum