2015-12-01 17 views
0

我想通過SSH在C#中使用SSH.NET連接到Azure Linux虛擬機。通過C#中的SSH連接到Ubuntu VM

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

不過,我收到以下異常:

No suitable authentication method found to complete authentication 

我能夠在Git中bash和膩子使用這些憑據SSH,是什麼問題?

回答

0

這意味着你的服務器拒絕這個連接方法。通常,SSH服務器只允許公共密鑰身份驗證或其他雙因素身份驗證。

更改/etc/ssh/sshd_config取消註釋#PasswordAuthentication yes

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

我檢查sshd_config中,並且已經設爲#PasswordAuthentication肯定。是否有其他可能導致此問題的配置設置? –

+0

取消註釋它,刪除hastag所以它會變成'PasswordAuthentication yes' – Ansel

+0

謝謝 - 這是做伎倆 –