I have developed a VB.NET Windows Service running under XP. I need to transfer files to a secured FTP site so have downloaded your VB.NET Assembly. I initially downloaded 4.3.8 of WinSCP but when I first attempted to connect with the VB.NET it told me the versions did not match so I downloaded and installed 5.0.7 of WinSCP. I'm able to connect to my server with the GUI and transfer files. Each time I connect I get a warning about connecting to the server but then it connects and I can transfer files. From VB.NET I get the message "Connection has been unexpectedly closed. Server sent command exit status 0.". I viewed your error list but nothing seemed to help.
Next I produced a log using Session.SessionLogPath and it appears that it's expecting a Password? Why when I've provided it with a Host Key? I've used the GUI so I know the username is correct and connected leaving the password blank. I'll post my code first (with security info removed) and then the log.
Thanks in advance.
Dim sessionOptions As New SessionOptions
.Protocol = Protocol.Sftp
.HostName = SFTPServerName
.UserName = Username
.Password = ""
.SshHostKey = SFTPServerKey
Using session As Session = New Session
session.SessionLogPath = OutputFolder & "WinSCP.log"
' Upload files
Dim transferOptions As New TransferOptions
transferOptions.TransferMode = TransferMode.Binary
Dim transferResult As TransferOperationResult
transferResult = session.PutFiles(FileToBeSent, SFTPServerDir, False, transferOptions)
' Throw on any error
' Print results
Dim transfer As TransferEventArgs
For Each transfer In transferResult.Transfers
bErr = util.SaveTextToFile(Now().ToString & " Transferred: " & FileToBeSent & ".", OutputFolder & "Transactions.log", ErrInfo)
. 2012-06-28 19:40:42.953 Looking up host "sftp.xxxxx.com"
. 2012-06-28 19:40:42.953 Connecting to 99.999.999.999 port 22
. 2012-06-28 19:40:43.046 Server version: SSH-2.0-1.36 sshlib: GlobalScape
. 2012-06-28 19:40:43.046 We believe remote version ignores SSH-2 maximum packet size
. 2012-06-28 19:40:43.046 Using SSH protocol version 2
. 2012-06-28 19:40:43.046 We claim version: SSH-2.0-WinSCP_release_5.0.7
. 2012-06-28 19:40:43.093 Using Diffie-Hellman with standard group "group1"
. 2012-06-28 19:40:43.093 Doing Diffie-Hellman key exchange with hash SHA-1
. 2012-06-28 19:40:43.421 Verifying host key dss 0xb92c47e49b8df5f80c1740a0c38021eb1cead9b982...
. 2012-06-28 19:40:43.421 Host key matches configured key
. 2012-06-28 19:40:43.421 Host key fingerprint is:
. 2012-06-28 19:40:43.421 ssh-dss 1024 86:08:93:00:55:be:b5:0c:3c:92:97:85:3f:f4:09:46
. 2012-06-28 19:40:43.421 Initialised Blowfish-128 CBC client->server encryption
. 2012-06-28 19:40:43.421 Initialised HMAC-SHA1 client->server MAC algorithm
. 2012-06-28 19:40:43.421 Initialised Blowfish-128 CBC server->client encryption
. 2012-06-28 19:40:43.421 Initialised HMAC-SHA1 server->client MAC algorithm
! 2012-06-28 19:40:43.671 Using username "email@example.com".
. 2012-06-28 19:40:43.718 Prompt (7, SSH password, , &Password: )
. 2012-06-28 19:40:43.718 Disconnected: Unable to authenticate