Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

martin

Re: Did you resolve this

@george338: And I have the same answer for you: Please post session log files both from the code and GUI. Did you use GUI to generate your code template?
george338

Did you resolve this

I am having a similar issue.
rwest11

SFTP Further Auth required

Hi Guys,

I'm trying to connect to a remote server via SFTP
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
 
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = "sftp"
    SshHostKeyFingerprint = "ssh-rsa 2048 ######c1mPs7MODjkyCxawY+wIAn1m7UmV4NdPE="
    HostName = "ftp.site.co.uk"
    UserName = "username"
    Password = "pass"   
}
$session = New-Object WinSCP.Session
 
# Connect
$session.Open($sessionOptions)

The credentials work in a GUI session but I get the below error in my script.
Exception calling "Open" with "1" argument(s): "Connection has been unexpectedly closed. Server sent command exit status 0.

Authentication log (see session log for details):
Using username "excanf".
Further authentication required
Authentication failed."
At C:\secure-file-transfer-project\Powershell-Scripts\CR_Stockfile_Import.ps1:22 char:9
+         $session.Open($sessionOptions)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SessionRemoteException

Any assistance would be appreciated

Ryan