I can´t connect with private key without password

Advertisement

Nacho
Joined:
Posts:
2
Location:
Zaragoza

I can´t connect with private key without password

Hi,

I trying to connect SFTP with .ppk file without password with .NET assembly with session options C#, this is my code
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.Protocol = Protocol.Sftp;
sessionOptions.HostName = "xxx.xxx.xxx.xxx";
sessionOptions.PortNumber = 22;
sessionOptions.UserName = "user";
sessionOptions.SshPrivateKeyPath = path
 
using (Session session = new Session())
{
   try
   {
       session.Open(sessionOptions);
   }
   catch (Exception ex)
   {
       MessageBox.Show(ex.Message);
   }
}
The message I receive when trying is:
SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set
I try to connect with the graphical interface with the same configuration and it works at the first.

Some suggestion?
Thanks!!!!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
38,166
Location:
Prague, Czechia

Re: I can´t connect with private key without password

Well, so do what the message says:
SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set

Set the SessionOptions.SshHostKeyFingerprint.
https://winscp.net/eng/docs/library_sessionoptions#sshhostkeyfingerprint

If you can login in GUI, it can generate a working code template for you:
https://winscp.net/eng/docs/ui_generateurl#code

Reply with quote

Nacho

Re: I can´t connect with private key without password

Thank you! I scan fingerprint and add to SessionOptions.SshHostKeyFingerprint and it works perfectly. Now I need a dll that works fine with 32 bit.

Reply with quote

martin
Site Admin
martin avatar

Re: I can´t connect with private key without password

Nacho wrote:

Now I need a dll that works find with 32 bit
WinSCP .NET assembly works both in 32 and 64-bit.

Reply with quote

Advertisement

You can post new topics in this forum