Hey I'm trying to write a script to automatically upload a file to another company's FTP site, but I am running in circles and keep getting the same error message. This is my first job and first time trying to write something like this so be gentle. We are not using a password to login, we use a username and a private key to authenticate. Below you can find my script and the log file of the issue.
Script: aka test.txt
option batch abort
option confirm off
open sftp://Gallagher@qa.gis.parker.com -privatekey=mykey.ppk -hostkey="sh-rsa 1024 2e:b9:10:43:83:55:69:84:0b:f5:b6:40:60:7c:5d:4c"
cd /home/iZap
put C:\Users\iZap\Documents\Parker /
exit
Batch file:
winscp.com /script=test.txt
Log File:
. 2020-05-04 16:08:18.463 Looking up host "qa.gis.parker.com" for SSH connection
. 2020-05-04 16:08:18.463 Connecting to 12.4.27.141 port 22
. 2020-05-04 16:08:18.510 We claim version: SSH-2.0-WinSCP_release_5.17.5
. 2020-05-04 16:08:18.542 Remote version: SSH-2.0-SFTP Server
. 2020-05-04 16:08:18.542 Using SSH protocol version 2
. 2020-05-04 16:08:18.542 No GSSAPI security context available
. 2020-05-04 16:08:18.542 Have a known host key of type rsa2
. 2020-05-04 16:08:18.542 Doing Diffie-Hellman group exchange
. 2020-05-04 16:08:18.791 Doing Diffie-Hellman key exchange using 4032-bit modulus and hash SHA-256 with a server-supplied group
. 2020-05-04 16:08:19.775 Host key fingerprint is:
. 2020-05-04 16:08:19.775 ssh-rsa 1024 2e:b9:10:43:83:55:69:84:0b:f5:b6:40:60:7c:5d:4c 1IXtQwUc5xhTwaynYWTjNelGlvvQaURyUMX+eWbanVY=
. 2020-05-04 16:08:19.822 Host key matches cached key
. 2020-05-04 16:08:19.822 Initialised AES-256 SDCTR (AES-NI accelerated) outbound encryption
. 2020-05-04 16:08:19.822 Initialised HMAC-SHA-256 outbound MAC algorithm
. 2020-05-04 16:08:19.822 Initialised AES-256 SDCTR (AES-NI accelerated) inbound encryption
. 2020-05-04 16:08:19.822 Initialised HMAC-SHA-256 inbound MAC algorithm
. 2020-05-04 16:08:19.869 Reading key file "C:\Users\iZap\mykey.ppk"
. 2020-05-04 16:08:19.869 Pageant is running. Requesting keys.
. 2020-05-04 16:08:19.869 Pageant has 1 SSH-2 keys
. 2020-05-04 16:08:19.869 Pageant key #0 matches configured key file
! 2020-05-04 16:08:19.869 Using username "Gallagher".
! 2020-05-04 16:08:19.948 SSH Server supporting SFTP and SCP
. 2020-05-04 16:08:19.948 Server offered these authentication methods: publickey
. 2020-05-04 16:08:19.948 Trying Pageant key #0
! 2020-05-04 16:08:20.026 Authenticating with public key "imported-openssh-key" from agent
. 2020-05-04 16:08:20.104 Sending Pageant's response
. 2020-05-04 16:08:20.197 Access granted
. 2020-05-04 16:08:20.197 Opening main session channel
. 2020-05-04 16:08:20.245 Opened main channel
. 2020-05-04 16:08:20.276 Started a shell/command
. 2020-05-04 16:08:20.291 Doing startup conversation with host.
> 2020-05-04 16:08:20.307 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2020-05-04 16:08:20.354 Type: SSH_FXP_VERSION, Size: 34, Number: -1
. 2020-05-04 16:08:20.354 SFTP version 3 negotiated.
. 2020-05-04 16:08:20.354 Unknown server extension newline@vandyke.com="\r\n"
. 2020-05-04 16:08:20.354 We believe the server has signed timestamps bug
. 2020-05-04 16:08:20.354 We will use UTF-8 strings until server sends an invalid UTF-8 string as with SFTP version 3 and older UTF-8 strings are not mandatory
. 2020-05-04 16:08:20.354 Changing directory to "/".
. 2020-05-04 16:08:20.354 Getting real path for '/'
> 2020-05-04 16:08:20.354 Type: SSH_FXP_REALPATH, Size: 10, Number: 80912
< 2020-05-04 16:08:20.416 Type: SSH_FXP_NAME, Size: 51, Number: 80912
. 2020-05-04 16:08:20.416 Real path is '/'
. 2020-05-04 16:08:20.416 Trying to open directory "/".
> 2020-05-04 16:08:20.416 Type: SSH_FXP_LSTAT, Size: 10, Number: 81159
< 2020-05-04 16:08:20.479 Type: SSH_FXP_ATTRS, Size: 37, Number: 81159
. 2020-05-04 16:08:20.479 Getting current directory name.
. 2020-05-04 16:08:20.525 Directory content loaded from cache.
. 2020-05-04 16:08:20.541 Cached directory not reloaded.
. 2020-05-04 16:08:20.572 Listing directory "/".
> 2020-05-04 16:08:20.572 Type: SSH_FXP_OPENDIR, Size: 10, Number: 81419
< 2020-05-04 16:08:20.619 Type: SSH_FXP_HANDLE, Size: 10, Number: 81419
> 2020-05-04 16:08:20.619 Type: SSH_FXP_READDIR, Size: 10, Number: 81676
< 2020-05-04 16:08:20.682 Type: SSH_FXP_NAME, Size: 116, Number: 81676
> 2020-05-04 16:08:20.682 Type: SSH_FXP_READDIR, Size: 10, Number: 81932
< 2020-05-04 16:08:20.713 Type: SSH_FXP_STATUS, Size: 45, Number: 81932
< 2020-05-04 16:08:20.713 Status code: 1
> 2020-05-04 16:08:20.713 Type: SSH_FXP_CLOSE, Size: 10, Number: 82180
. 2020-05-04 16:08:20.713 drives;d;0;2020-05-04T20:07:35.000Z;3;"300" [300];"100" [100];rwx------;0
. 2020-05-04 16:08:20.713 ..;D;0;1899-12-30T05:00:00.000Z;0;"" [0];"" [0];---------;0
. 2020-05-04 16:08:20.776 Startup conversation with host finished.
. 2020-05-04 16:09:25.991 Session sent command exit status 0
. 2020-05-04 16:09:25.991 Main session channel closed
. 2020-05-04 16:09:27.492 All channels closed
. 2020-05-04 16:09:27.990 Attempt to close connection due to fatal exception:
* 2020-05-04 16:09:27.990 **Connection has been unexpectedly closed.** Server sent command exit status 0.
. 2020-05-04 16:09:27.990 Closing connection.
* 2020-05-04 16:09:27.990 (ESshFatal) **Connection has been unexpectedly closed.** Server sent command exit status 0.