SessionOptions.SshPrivateKeyPath is set, but SessionOptions.Protocol

Advertisement

smarazzi62
Joined:
Posts:
1
Location:
italia

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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

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.

Reply with quote

Advertisement

You can post new topics in this forum