-
-
Notifications
You must be signed in to change notification settings - Fork 963
Closed
Description
Hey,
Maybe i am missing the obvious here, but i see no reason why my connection should not work.
The Key is already converted into something SSH.net usable:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,
...
-----END RSA PRIVATE KEY-----
and a corresponding ssh call shows the public key is registered on the server correctly:
ssh DOMAIN -l root -i C:\Users\XXXX\.ssh\id_XXXX
-> Works
Then why does this code throws an exception on connect?
var connectionInfo = new ConnectionInfo(uploadTargetHost,
sshUser,
new PrivateKeyAuthenticationMethod(sshUser, new PrivateKeyFile(@"C:\Users\XXXX\.ssh\id_XXXX", keyPassword)));
using var client = new SftpClient(connectionInfo);
EventHandler<HostKeyEventArgs> clientOnHostKeyReceived = (sender, e) =>
{
e.CanTrust = true;
};
client.HostKeyReceived += clientOnHostKeyReceived;
client.Connect();
Renci.SshNet.Common.SshAuthenticationException: 'Permission denied (publickey).'