Skip to content

'Permission denied (publickey).' but terminal ssh connection works fine #1145

Description

@JPVenson

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?

varconnectionInfo=newConnectionInfo(uploadTargetHost,sshUser,newPrivateKeyAuthenticationMethod(sshUser,newPrivateKeyFile(@"C:\Users\XXXX\.ssh\id_XXXX",keyPassword)));usingvarclient=newSftpClient(connectionInfo);EventHandler<HostKeyEventArgs>clientOnHostKeyReceived=(sender,e)=>{e.CanTrust=true;};client.HostKeyReceived+=clientOnHostKeyReceived;client.Connect();
Renci.SshNet.Common.SshAuthenticationException: 'Permission denied (publickey).'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions