Thanks a tons!! Such a stupid mistake on my part.
Another question. The same script, connects to the host 3 times... I don't understand why. Can you explain? Is there a way to connect only once? and instead of supplying the parameter to the script can I just connect via commandline and just execute the script after?
. 2014-01-25 12:00:43.030 --------------------------------------------------------------------------
. 2014-01-25 12:00:43.045 WinSCP Version 4.3.8 (Build 1771) (OS 6.1.7601 Service Pack 1)
. 2014-01-25 12:00:43.048 Login time: Saturday, 25 January, 2014 12:00:43
. 2014-01-25 12:00:43.049 --------------------------------------------------------------------------
. 2014-01-25 12:00:43.049 Session name: example@example.com (Ad-Hoc session)
. 2014-01-25 12:00:43.049 Host name: example.com (Port: 22)
. 2014-01-25 12:00:43.049 User name: example (Password: No, Key file: No)
. 2014-01-25 12:00:43.049 Tunnel: No
. 2014-01-25 12:00:43.049 Transfer Protocol: SFTP (SCP)
. 2014-01-25 12:00:43.049 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2014-01-25 12:00:43.049 Proxy: none
. 2014-01-25 12:00:43.049 SSH protocol version: 2; Compression: No
. 2014-01-25 12:00:43.049 Bypass authentication: No
. 2014-01-25 12:00:43.049 Try agent: Yes; Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2014-01-25 12:00:43.049 Ciphers: aes,blowfish,3des,WARN,arcfour,des; Ssh2DES: No
. 2014-01-25 12:00:43.049 SSH Bugs: -,-,-,-,-,-,-,-,-
. 2014-01-25 12:00:43.049 SFTP Bugs: -,-
. 2014-01-25 12:00:43.049 Return code variable: Autodetect; Lookup user groups: Yes
. 2014-01-25 12:00:43.049 Shell: default
. 2014-01-25 12:00:43.049 EOL: 0, UTF: 2
. 2014-01-25 12:00:43.050 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2014-01-25 12:00:43.050 LS: ls -la, Ign LS warn: Yes, Scp1 Comp: No
. 2014-01-25 12:00:43.050 Local directory: default, Remote directory: home, Update: No, Cache: Yes
. 2014-01-25 12:00:43.050 Cache directory changes: Yes, Permanent: Yes
. 2014-01-25 12:00:43.050 DST mode: 1
. 2014-01-25 12:00:43.050 --------------------------------------------------------------------------
. 2014-01-25 12:00:43.079 Looking up host "example.com"
. 2014-01-25 12:00:47.219 Connecting to 11.222.111.222 port 22
. 2014-01-25 12:00:51.645 Server version: SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze2
. 2014-01-25 12:00:51.645 Using SSH protocol version 2
. 2014-01-25 12:00:51.645 We claim version: SSH-2.0-WinSCP_release_4.3.8
. 2014-01-25 12:00:52.060 Doing Diffie-Hellman group exchange
. 2014-01-25 12:00:52.958 Doing Diffie-Hellman key exchange with hash SHA-1
. 2014-01-25 12:00:53.633 Host key fingerprint is:
. 2014-01-25 12:00:53.633 ssh-rsa 2048 1b:88:d0:1c:be:e5:31:be:b7:0a:dd:91:d8:99:d6:12
. 2014-01-25 12:00:53.633 Initialised AES-256 SDCTR client->server encryption
. 2014-01-25 12:00:53.633 Initialised HMAC-SHA1 client->server MAC algorithm
. 2014-01-25 12:00:53.633 Initialised AES-256 SDCTR server->client encryption
. 2014-01-25 12:00:53.633 Initialised HMAC-SHA1 server->client MAC algorithm
. 2014-01-25 12:00:54.527 Pageant is running. Requesting keys.
. 2014-01-25 12:00:54.527 Pageant has 1 SSH-2 keys
! 2014-01-25 12:00:54.528 Using username "example".
. 2014-01-25 12:00:55.009 Trying Pageant key #0
! 2014-01-25 12:00:55.521 Authenticating with public key "SampleKey" from agent
. 2014-01-25 12:00:55.538 Sending Pageant's response
. 2014-01-25 12:00:56.011 Access granted
. 2014-01-25 12:00:56.500 Opened channel for session
. 2014-01-25 12:00:57.613 Started a shell/command
. 2014-01-25 12:00:57.613 --------------------------------------------------------------------------
. 2014-01-25 12:00:57.640 Using SFTP protocol.
. 2014-01-25 12:00:57.642 Doing startup conversation with host.
> 2014-01-25 12:00:57.695 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2014-01-25 12:00:58.123 Type: SSH_FXP_VERSION, Size: 95, Number: -1
. 2014-01-25 12:00:58.124 SFTP version 3 negotiated.
. 2014-01-25 12:00:58.124 Unknown server extension posix-rename@openssh.com="1"
. 2014-01-25 12:00:58.124 Unknown server extension statvfs@openssh.com="2"
. 2014-01-25 12:00:58.124 Unknown server extension fstatvfs@openssh.com="2"
. 2014-01-25 12:00:58.124 We believe the server has signed timestamps bug
. 2014-01-25 12:00:58.124 We will use UTF-8 strings for status messages only
. 2014-01-25 12:00:58.124 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2014-01-25 12:00:58.124 Getting current directory name.
. 2014-01-25 12:00:58.124 Getting real path for '.'
> 2014-01-25 12:00:58.126 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2014-01-25 12:00:58.525 Type: SSH_FXP_NAME, Size: 51, Number: 16
. 2014-01-25 12:00:58.526 Real path is '/home/example'
. 2014-01-25 12:00:58.526 Startup conversation with host finished.
< 2014-01-25 12:00:58.526 Script: Active session: [1] example@example.com
> 2014-01-25 12:00:58.527 Script: option transfer binary
< 2014-01-25 12:00:58.528 Script: transfer binary
> 2014-01-25 12:00:58.529 Script: call umask 077
< 2014-01-25 12:00:58.529 Script: Searching for host...
. 2014-01-25 12:00:58.530 [Shell] Looking up host "example.com"
. 2014-01-25 12:00:58.536 [Shell] Connecting to 11.222.111.222 port 22
< 2014-01-25 12:00:59.013 Script: Connecting to host...
. 2014-01-25 12:00:59.635 [Shell] Server version: SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze2
. 2014-01-25 12:00:59.635 [Shell] Using SSH protocol version 2
. 2014-01-25 12:00:59.635 [Shell] We claim version: SSH-2.0-WinSCP_release_4.3.8
. 2014-01-25 12:01:00.103 [Shell] Doing Diffie-Hellman group exchange
. 2014-01-25 12:01:00.970 [Shell] Doing Diffie-Hellman key exchange with hash SHA-1
< 2014-01-25 12:01:01.717 Script: Authenticating...
. 2014-01-25 12:01:01.718 [Shell] Host key fingerprint is:
. 2014-01-25 12:01:01.718 [Shell] ssh-rsa 2048 1b:88:d0:1c:be:e5:31:be:b7:0a:dd:91:d8:99:d6:12
. 2014-01-25 12:01:01.718 [Shell] Initialised AES-256 SDCTR client->server encryption
. 2014-01-25 12:01:01.718 [Shell] Initialised HMAC-SHA1 client->server MAC algorithm
. 2014-01-25 12:01:01.718 [Shell] Initialised AES-256 SDCTR server->client encryption
. 2014-01-25 12:01:01.718 [Shell] Initialised HMAC-SHA1 server->client MAC algorithm
. 2014-01-25 12:01:02.659 [Shell] Pageant is running. Requesting keys.
. 2014-01-25 12:01:02.659 [Shell] Pageant has 1 SSH-2 keys
! 2014-01-25 12:01:02.660 [Shell] Using username "example".
< 2014-01-25 12:01:02.660 Script: Using username "example".
. 2014-01-25 12:01:03.135 [Shell] Trying Pageant key #0
! 2014-01-25 12:01:04.236 [Shell] Authenticating with public key "SampleKey" from agent
< 2014-01-25 12:01:04.236 Script: Authenticating with public key "SampleKey" from agent.
. 2014-01-25 12:01:04.259 [Shell] Sending Pageant's response
. 2014-01-25 12:01:04.639 [Shell] Access granted
. 2014-01-25 12:01:05.012 [Shell] Opened channel for session
. 2014-01-25 12:01:05.784 [Shell] Started a shell/command
< 2014-01-25 12:01:05.784 Script: Authenticated.
. 2014-01-25 12:01:05.785 [Shell] --------------------------------------------------------------------------
. 2014-01-25 12:01:05.785 [Shell] Using SCP protocol.
. 2014-01-25 12:01:05.785 [Shell] Doing startup conversation with host.
< 2014-01-25 12:01:05.785 Script: Starting the session...
. 2014-01-25 12:01:05.786 [Shell] Skipping host startup message (if any).
> 2014-01-25 12:01:05.787 [Shell] echo "WinSCP: this is end-of-file:0"
< 2014-01-25 12:01:05.787 [Shell] Welcome to example.com
< 2014-01-25 12:01:05.787 [Shell] Any malicious and/or unauthorized activity is strictly forbidden.
< 2014-01-25 12:01:05.787 [Shell] All activity may be logged by DreamHost Web Hosting.
< 2014-01-25 12:01:06.646 [Shell] WinSCP: this is end-of-file:0
. 2014-01-25 12:01:06.646 [Shell] Detecting variable containing return code of last command.
. 2014-01-25 12:01:06.646 [Shell] Trying "$status".
> 2014-01-25 12:01:06.646 [Shell] echo "$status" ; echo "WinSCP: this is end-of-file:0"
< 2014-01-25 12:01:07.480 [Shell] WinSCP: this is end-of-file:0
. 2014-01-25 12:01:07.480 [Shell] The response is not numerical exit code
. 2014-01-25 12:01:07.481 [Shell] Trying "$?".
> 2014-01-25 12:01:07.482 [Shell] echo "$?" ; echo "WinSCP: this is end-of-file:0"
< 2014-01-25 12:01:08.262 [Shell] 0
< 2014-01-25 12:01:08.262 [Shell] WinSCP: this is end-of-file:0
. 2014-01-25 12:01:08.262 [Shell] Return code variable "$?" selected.
< 2014-01-25 12:01:08.262 Script: Reading remote directory...
. 2014-01-25 12:01:08.263 [Shell] Changing directory to "/home/example".
> 2014-01-25 12:01:08.263 [Shell] cd "/home/example" ; echo "WinSCP: this is end-of-file:$?"
< 2014-01-25 12:01:09.181 [Shell] WinSCP: this is end-of-file:0
. 2014-01-25 12:01:09.181 [Shell] Getting current directory name.
> 2014-01-25 12:01:09.181 [Shell] pwd ; echo "WinSCP: this is end-of-file:$?"
< 2014-01-25 12:01:10.004 [Shell] /home/example
< 2014-01-25 12:01:10.004 [Shell] WinSCP: this is end-of-file:0
. 2014-01-25 12:01:10.004 [Shell] Startup conversation with host finished.
< 2014-01-25 12:01:10.004 Script: Session started.
. 2014-01-25 12:01:10.006 Executing user defined command on command session.
> 2014-01-25 12:01:10.007 [Shell] umask 077 ; echo "WinSCP: this is end-of-file:$?"
< 2014-01-25 12:01:10.976 [Shell] WinSCP: this is end-of-file:0
> 2014-01-25 12:01:10.976 [Shell] pwd ; echo "WinSCP: this is end-of-file:$?"
< 2014-01-25 12:01:11.816 [Shell] /home/example
< 2014-01-25 12:01:11.816 [Shell] WinSCP: this is end-of-file:0
. 2014-01-25 12:01:11.816 Cached directory change via "/home/example" to "/home/example".
. 2014-01-25 12:01:11.818 Getting current directory name.
. 2014-01-25 12:01:11.818 Getting current directory name.
> 2014-01-25 12:01:11.819 Script: call test -d .ssh || mkdir .ssh
. 2014-01-25 12:01:11.819 Executing user defined command on command session.
> 2014-01-25 12:01:11.819 [Shell] test -d .ssh || mkdir .ssh ; echo "WinSCP: this is end-of-file:$?"
< 2014-01-25 12:01:12.694 [Shell] WinSCP: this is end-of-file:0
> 2014-01-25 12:01:12.694 [Shell] pwd ; echo "WinSCP: this is end-of-file:$?"
< 2014-01-25 12:01:13.550 [Shell] /home/example
< 2014-01-25 12:01:13.550 [Shell] WinSCP: this is end-of-file:0
. 2014-01-25 12:01:13.550 Cached directory change via "/home/example" to "/home/example".
. 2014-01-25 12:01:13.550 Getting current directory name.
. 2014-01-25 12:01:13.550 Getting current directory name.
> 2014-01-25 12:01:13.550 Script: put -append .\ExternalTools\id_rsa.pub .ssh/authorized_keys
. 2014-01-25 12:01:13.551 Copying 1 files/directories to remote directory ".ssh/"
. 2014-01-25 12:01:13.551 PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 01; Resume: S (102400); CalcS: No; Mask: authorized_keys
. 2014-01-25 12:01:13.551 TM: B; ClAr: No; CPS: 0; ExclM(No):
. 2014-01-25 12:01:13.551 AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2014-01-25 12:01:13.551 File: ".\ExternalTools\id_rsa.pub"
. 2014-01-25 12:01:13.559 Copying ".\ExternalTools\id_rsa.pub" to remote directory started.
. 2014-01-25 12:01:13.559 Binary transfer mode selected.
. 2014-01-25 12:01:13.559 Opening remote file.
> 2014-01-25 12:01:13.560 Type: SSH_FXP_OPEN, Size: 61, Number: 259
< 2014-01-25 12:01:14.009 Type: SSH_FXP_STATUS, Size: 24, Number: 259
< 2014-01-25 12:01:14.009 Status code: 4, Message: 259, Server: Failure, Language:
> 2014-01-25 12:01:14.010 Type: SSH_FXP_LSTAT, Size: 45, Number: 519
< 2014-01-25 12:01:14.385 Type: SSH_FXP_ATTRS, Size: 37, Number: 519
> 2014-01-25 12:01:14.432 Type: SSH_FXP_OPEN, Size: 53, Number: 771
< 2014-01-25 12:01:14.806 Type: SSH_FXP_HANDLE, Size: 13, Number: 771
. 2014-01-25 12:01:14.806 Appending file.
> 2014-01-25 12:01:14.808 Type: SSH_FXP_WRITE, Size: 234, Number: 1286
> 2014-01-25 12:01:14.808 Type: SSH_FXP_CLOSE, Size: 13, Number: 1540
> 2014-01-25 12:01:14.808 Type: SSH_FXP_SETSTAT, Size: 57, Number: 1033
< 2014-01-25 12:01:15.184 Type: SSH_FXP_STATUS, Size: 24, Number: 1286
< 2014-01-25 12:01:15.588 Type: SSH_FXP_STATUS, Size: 24, Number: 1540
< 2014-01-25 12:01:15.588 Status code: 0
< 2014-01-25 12:01:15.588 Type: SSH_FXP_STATUS, Size: 24, Number: 1033
< 2014-01-25 12:01:15.621 Status code: 0
> 2014-01-25 12:01:15.624 Script: close
. 2014-01-25 12:01:15.624 Closing connection.
. 2014-01-25 12:01:15.624 Sending special code: 12
. 2014-01-25 12:01:15.624 Sent EOF message
. 2014-01-25 12:01:15.625 [Shell] Closing connection.
. 2014-01-25 12:01:15.625 [Shell] Sending special code: 12
. 2014-01-25 12:01:15.625 [Shell] Sent EOF message