SSHAuthenticationExcetion:找不到合适的身份验证方法来完成身份验证

时间:2013-07-03 19:49:33

标签: vb.net winforms unix ssh

我正在尝试使用vb.net win表单连接服务器。我放了一个按钮和一个文本区域来接收数据。但是我无法在服务器上连接。服务器是开放的,因为我可以ping它。

Private Sub SimpleButton1_Click(sender As System.Object, e As System.EventArgs) Handles SimpleButton1.Click
    Dim PasswordConnection = New PasswordAuthenticationMethod("username", "pass")
    Dim KeyboardInteractive = New KeyboardInteractiveAuthenticationMethod("username")
    Dim ConnectionInfo = New ConnectionInfo("server.com", 22, "username", PasswordConnection, KeyboardInteractive)

    Using client As New SshClient(ConnectionInfo)
        client.Connect()

        Dim cmd As SshCommand
        Dim result As String
        Dim result2 As String

        cmd = client.CreateCommand("who")
        cmd.CommandTimeout = TimeSpan.FromSeconds(10)
        result = cmd.Execute
        result2 = cmd.Error
        MemoEdit1.Text = cmd.ExitStatus

        If String.IsNullOrEmpty(result2) Then
            MemoEdit1.Text = result2
        End If

        MemoEdit1.Text = result

        client.Disconnect()
    End Using
End Sub

我做错了吗? 该程序直接停留在“client.Connect()”上。正如您所看到的,我试图在事件上连接点击SimpleButton1

1 个答案:

答案 0 :(得分:5)

当服务器不允许客户端提供的方法进行身份验证时,通常会从SSH服务器返回No suitable authentication method found to complete authentication is used

SSH服务器只能允许公钥认证,或者某种形式的双因素认证反过来阻止密码认证。下载Putty之类的SSH客户端,尝试直接连接到服务器,看看结果如何。