简体   繁体   中英

Connect to Ubuntu VM via SSH in C#

I am trying to connect to an Azure Linux vm via SSH in C# using SSH.NET.

using (var client = new SshClient("my-vm.cloudapp.net", 22, "username", "password​"))
        {
            client.Connect();
            Console.WriteLine("it worked!");
            client.Disconnect();
            Console.ReadLine();
        }

However, I am getting the following exception:

No suitable authentication method found to complete authentication

I am able to to ssh in using these credentials in git bash and Putty, what is the problem?

It means your server reject this method to connect. Usually SSH server only allow public key auth or other two factor auth.

Change your /etc/ssh/sshd_config uncomment #PasswordAuthentication yes

 # Change to no to disable tunnelled clear text passwords
 #PasswordAuthentication yes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM