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

martin

Re: SCP Protocol Failing with Blank Password (.NET)

Thanks for your report.

This issue has been added to the tracker:
https://winscp.net/tracker/1638
ipwillia

Log File

Adding log from successful WinSCP.exe GUI connection
ipwillia

Log file

Adding log from WinSCPnet.dll
ipwillia

SCP Protocol Failing with Blank Password (.NET)

Using WinSCPnet.dll and WinSCP.exe version 5.7.7.0
.NET 4.5


SessionOptions sessionOptions = new SessionOptions();

sessionOptions.Protocol = Protocol.Scp;
sessionOptions.HostName = mtpAddress; //IP Address
sessionOptions.UserName = "root";
sessionOptions.Password = "";
sessionOptions.PortNumber = 22;
sessionOptions.GiveUpSecurityAndAcceptAnySshHostKey = true;

using (Session session = new Session())
{
    //Connect
    session.Open(sessionOptions); //<------------------------------------------FAILS HERE

    // Upload files
    TransferOptions transferOptions = new TransferOptions();
    transferOptions.TransferMode = TransferMode.Binary;

    TransferOperationResult transferResult;
    transferResult = session.GetFiles(sourceFilePath, destinationFilePath, removeSource, transferOptions);

    // Throw on any error
    transferResult.Check();
}



I get the following error message:
An unhandled exception of type 'WinSCP.SessionRemoteException' occurred in WinSCPnet.dll

Additional information: Connection has been unexpectedly closed. Server sent command exit status 0.


Things to note:
    The same credentials work with the WinSCP.exe GUI
    I'm using SCP, not SFTP
    Password is blank (""). Have also tried null with the same result.


Any help would be greatly appreciated. Thank you!