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

benalex84

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).