【问题标题】:Connect to Ubuntu VM via SSH in C#在 C# 中通过 SSH 连接到 Ubuntu VM
【发布时间】:2015-12-03 01:47:43
【问题描述】:

我正在尝试使用 SSH.NET 在 C# 中通过 SSH 连接到 Azure Linux 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

我可以通过 ssh 在 git bash 和 Putty 中使用这些凭据,有什么问题?

【问题讨论】:

    标签: c# linux azure ssh


    【解决方案1】:

    这意味着您的服务器拒绝此方法连接。通常 SSH 服务器只允许公钥认证或其他两因素认证。

    更改您的/etc/ssh/sshd_configuncomment #PasswordAuthentication yes

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

    【讨论】:

    • 我检查了 sshd_config,它已经设置为 #PasswordAuthentication 是的。是否有任何其他配置设置可能导致此问题?
    • 取消注释,去掉hastag,它会变成PasswordAuthentication yes
    • 如果它有效,不要忘记接受这个作为答案,这样它也会帮助有同样问题的人
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-15
    • 1970-01-01
    • 2020-09-14
    • 2017-11-24
    • 1970-01-01
    相关资源
    最近更新 更多