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

Re: Connection has been unexpectedly closed Server sent command exit status 0

Does WinSCP GUI work? If not, can you connect and work with the server using any other SFTP client running on the same machine as WinSCP?
bhanney@...

Re: Connection has been unexpectedly closed Server sent command exit status 0

martin wrote:

Can you attach a complete session log file?



Not sure if you have any updates as to why this is occurring if its something I'm doing wrong or on the server side? But to give you an update, I've attached an updated log file. I attempted to try and run my script today 5/6/2020 at 14:59 in the log file and from there you can see I authenticate correctly and it seems like it finds the remote directory, but I can't confirm that a transfer has been successful. IT also ends with the same error session sent command exit status 0. Attached you can find the updated log and my script is found here below, I just got it from going to the file and choosing upload -> transfer settings -> generate code and I changed it to command line.

/log="C:\writable\path\to\log\WinSCP.log" /ini=nul /command "open sftp://Gallagher@qa.gis.parker.com/ -hostkey=""ssh-rsa 1024 1IXtQwUc5xhTwaynYWTjNelGlvvQaURyUMX+eWbanVY="" -privatekey=""C:\Users\iZap\mykey.ppk"" -rawsettings ProxyPort=0" "lcd C:\Users\iZap\Documents\Parker" "cd /" "put -rawtransfersettings[1] IgnorePermErrors=1 *" "exit"


Batch File:

winscp.com /script=script.txt

pause
Guest

Re: Connection has been unexpectedly closed Server sent command exit status 0

martin wrote:

Can you attach a complete session log file?


I have attached the session log of everything from yesterday to this morning.
martin

Re: Connection has been unexpectedly closed Server sent command exit status 0

Can you attach a complete session log file?
bhanney

Connection has been unexpectedly closed Server sent command exit status 0

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.