I'm doing some tests to connect to a host using VBA. There's no problem when I do in WinScp interface, but I'm having no success when I try using VBA.
This is the code I'm using:
Sub Conectar() Dim MySession As New WinSCPnet.Session Dim MySessionOptions As New WinSCPnet.SessionOptions On Error GoTo ErrorHandler MySession.SessionLogPath = CurrentProject.Path & "\Log\Log.txt" With MySessionOptions .Protocol = Protocol_Sftp .HostName = "ddddddddd.de.db.com" .UserName = "U111111" .Password = "MyPass" .PortNumber = 22 .SshHostKeyFingerprint = "ssh-dss 1024 26:b7:f5:fa:0e:0c:71:e6:3a:6e:de:b7:a9:d7:26:41" .SshPrivateKeyPath = "C:\Users\U111111\privatekeywinscp.ppk" End With MySession.Open MySessionOptions ExitProcedure: MySession.dispose Set MySessionOptions = Nothing Set MySession = Nothing Exit Sub ErrorHandler: MsgBox Err.Number & " - " & Err.Description GoTo ExitProcedure End Sub
The error fires in line MySession.Open MySessionOptions and is always the same "Connection has been unexpectedly closed. Server sent command exit status 0."
I asked for logging the "manual" session that executes from winscp interface and also asked for logging the "code" session. The "manual" logging session ends succesfulyy in this way
Prompt (passphrase, "SSH key passphrase", <no instructions>, "Passphrase for key "U111111": ")
Sent public key signature
Opening session as main channel
Opened main channel
Started a shell/command
The "code" logging goes well until
Prompt (3, SSH key passphrase, , Passphrase for key "U111111": )
Disconnected: Unable to authenticate
Thanks in advance :-)
Saludos from Barcelona (Spain)
Last edited by happy on 2016-01-05 19:55; edited 1 time in total