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: SessionOptions.SshPrivateKeyPath is set, but SessionOptions.Protocol

OK, so remove the SshPrivateKeyPath.
You probably have the key set in your GUI session settings. While GUI will ignore the key, if you set it for non-SSH session, the .NET assembly is more strict.
smarazzi62

SessionOptions.SshPrivateKeyPath is set, but SessionOptions.Protocol

hi,
i'm trying to connect to ftp site using .net assembly with session option c# code generated by winscp ui, as follow

// Set up session options
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "xxxxxxxxxx",
PortNumber = 21,
UserName = "xxxxxx",
Password = "xxxxx",
SshPrivateKeyPath = @"C:\Program Files\WinSCP\......PPK",
FtpMode = FtpMode.Active,
TimeoutInMilliseconds = 60000,
};

sessionOptions.AddRawSettings("ProxyHost", "xxx.xxx.xxx.xxx");
sessionOptions.AddRawSettings("ProxyPort", "1080");

using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);

// Your code
}


I can connect with winscp ui but i get the error
SessionOptions.SshPrivateKeyPath is set, but SessionOptions.Protocol is neither Protocol.Sftp nor Protocol.Scp.
when i use .net assembly in c# application.

Some suggestion?

thanks