SFTP Sync Script Error

Advertisement

Wecks
Joined:
Posts:
2
Location:
Weedon

SFTP Sync Script Error

I am using a PowerShell script posted on his site to transfer files from an SFTP site to a local server. Up until recently, it was working but stopped 2 weeks ago and looking at the log I am getting this error message when it runs.

[08/19/2019 12:20:31] Sync Started
[08/19/2019 12:20:31] Error: Exception calling "Open" with "1" argument(s): "Disconnected: No supported authentication methods available (server sent: publickey)
Authentication log (see session log for details):

I created a public/private key using putty and I obtained the fingerprint from the win SCP app but I am struggling to get past this. I know the keys have not changed. Does anyone have any ideas?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: SFTP Sync Script Error

Can you connect in WinSCP GUI?
If you can, post complete log file both from the GUI and your script.

Reply with quote

Guest

Solution

the solution to this issue has been found. For you information, if you use the SFTP scrip posted on the WINSCP site you will need to add the lines below in bold.

For some reason when the path to the Key and the passphrase was added it started to work. The parts in bold were added to resolve. (Parts in red are variables specific to your solution)

$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = "sftp.XXXXXXXX.com"
UserName = "USERNAME"
PrivateKeyPassphrase = "XXXXXXXXXXX"
SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
SshPrivateKeyPath = "C:\Keys\PRIVATEKEY.ppk"
}

Reply with quote

Advertisement

You can post new topics in this forum