Unable to authenticate to SFTP via PowerShell

Advertisement

benalex84
Guest

Unable to authenticate to SFTP via PowerShell

I am trying to write a PowerShell script to connect to an SFTP. I am using this example script without the file transfer. Just trying to open and close the connection. Whenever I run the script I get
Exception calling "Open" with "1" argument(s): "Authentication failed.
Authentication log (see session log for details):
Using username "<username>".
Access denied.
Authentication failed."
At C:\Scripts\ftpTest.ps1:38 char:5
+ $session.Open($sessionOptions)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SessionRemoteException
When I copy and paste the hostname, username, and password from my script to WinSCP GUI I am able to connect through the GUI. I am using SFTP protocol with an ecdsa-sha2-nistp256 fingerprint. I've tried converting the password to a SecureString and using SecurePassword, no difference. I tried setting the FTPS security implicit/explicit with no luck (obviously).

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum