Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

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.
graga

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.
martin

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.
graga

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.