You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to connect to an Ubuntu server with my private key, but I can't get it working
let execution () =
let connectionInfo = new ConnectionInfo(host, "root", new PrivateKeyAuthenticationMethod("./resources/keys/id_rsa"))
use client = new SshClient(connectionInfo)
do client.Connect()
()
do execution ()
The code is a F# script but I guess it's readable.
I tested the file to be reachable (looks like the exception if the path is wrong is the same) and I also tried using the key with ssh cli, succesfully. So the key should be good.
EDIT: the same error occurs using both the NuGet package and the current develop branch on GitHub
EDIT 2: i managed to get it working. This is the working code:
let execution () =
let connectionInfo = new ConnectionInfo(host, "root", new PrivateKeyAuthenticationMethod("root", new PrivateKeyFile("./resources/keys/id_rsa")))
use client = new SshClient(connectionInfo)
do client.Connect()
()
do execution ()
I see it's a bit redundant (having to specify twice the username). Is there a better way, similar to the multi-factor example?
Windows C#, .NET 4.5. I get permission denied just out of the blue, it worked fine and suddenly throws permission denied for every file, FileZilla works fine.
I got the same issue. It was working on my development machine running windows 10. When I deployed it to our production environment I get this message. Both are pointing to the same private key file.
@drieseng The single argument PrivateKeyAuthenticationMethod constructor is used in the multi-factor-authentication example in the README, I suppose it no longer works that way?
Activity
hovek commentedon Mar 5, 2018
Windows C#, .NET 4.5. I get permission denied just out of the blue, it worked fine and suddenly throws permission denied for every file, FileZilla works fine.
kranz912 commentedon Jun 8, 2018
I got the same issue. It was working on my development machine running windows 10. When I deployed it to our production environment I get this message. Both are pointing to the same private key file.
drieseng commentedon Jun 8, 2018
@gmlion: in the first code snippet you actually specified "./resources/keys/id_rsa" as user name, hence the authentication failure.
I agree that it's a bit weird to specify the user name twice. Please submit a separate issue for this.
drieseng commentedon Jun 8, 2018
@hovek, @kranz912: If you have more information (eg. server logs), please submit a separate issue.
@kranz912: Were you actually accessing the same SSH server on both your development machine and your production environment?
gmlion commentedon Jun 11, 2018
@drieseng The single argument PrivateKeyAuthenticationMethod constructor is used in the multi-factor-authentication example in the README, I suppose it no longer works that way?
hotyes commentedon Jul 7, 2022
hi @gmlion , have you solved this problem ? thanks
igavva commentedon Sep 19, 2023
A simple solution.
Add this line in /etc/ssh/sshd_config.
PubkeyAcceptedAlgorithms +ssh-rsa
Afterwards, restart the sshd service to make the new settings come into effect.
$ sudo systemctl restart sshd
WojciechNagorski commentedon Sep 23, 2023
Fixed by #1177 and #1180
WojciechNagorski commentedon Oct 10, 2023
Version 2023.0.0 has been published https://www.nuget.org/packages/SSH.NET/2023.0.0