4/29/2014

Auto login in WinSCP cmd

Create a script named "scp.script" with the following content.

option batch on
option confirm off
open sftp://MyAccount:MyPass@serverIP:22 -hostkey="ssh-rsa 1024 42:9e:c7:f4:7f:8b:50:10:6a:06:04:b1:d4:f2:04:6d"
dir
exit

Then run the script:

"C:\Program Files\WinSCP\WinSCP.com" /script:"scp.script"     
Here comes result:
batch           on
confirm         off
Searching for host...
Connecting to host...
Authenticating...
Using username "root".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] root@10.0.0.1
-rw-------   1 root     root         14376 Apr 11 14:30:29 2014 .mysql_history
-rw-r--r--   1 root     root           107 Apr 23 17:13:12 2013 .gtk-bookmarks