我第一次使用庫Renci.SshNet.dll。我下載了2014.4.6-beta2版本。「值不能爲空,參數名稱數據」與Renci.SshNet.sshclient.connect()的錯誤
我想SSH連接到服務器。當然,連接使用我的登錄名和密碼與Putty協同工作。
這裏是我的代碼:
Dim PWAuthMeth = New PasswordAuthenticationMethod(Login, Password)
Dim KIAuthMeth = New KeyboardInteractiveAuthenticationMethod(Login)
Dim ConnectionInfo As New ConnectionInfo(ServerName, 22, Login, PWAuthMeth, KIAuthMeth)
Dim SshClient1 As New SshClient(ConnectionInfo)
SshClient1.Connect()
的connect()方法給我一個ArgumentNullException,消息(法語):
「香格里拉valeur東北peut考績理由空喃杜paramètre :數據」
堆棧跟蹤:
à Renci.SshNet.KeyboardInteractiveAuthenticationMethod.Authenticate(Session session)
à Renci.SshNet.AuthenticationMethod.Renci.SshNet.IAuthenticationMethod.Authenticate(ISession session)
à Renci.SshNet.ClientAuthentication.TryAuthenticate(ISession session, AuthenticationState authenticationState, ICollection`1 allowedAuthenticationMethods, SshAuthenticationException& authenticationException)
à Renci.SshNet.ClientAuthentication.Authenticate(IConnectionInfoInternal connectionInfo, ISession session)
à Renci.SshNet.ConnectionInfo.Authenticate(ISession session)
à Renci.SshNet.Session.Connect()
à Renci.SshNet.BaseClient.Connect()
à ConsoleApplication1.Upload.LancerUpload() dans D:\Travail\ENSAM\Promotion\Logiciel\PromoAM-Export\PromoAM-Export\Class_Upload.vb:ligne 19
...
我試過其他版本的dll,但是錯誤是一樣的。
我發現這個話題:
Unable to connect to AIX(Unix) box with SSH.NET Library - Error : Value cannot be null
這個問題似乎非常相似,所以我嘗試到c#轉換爲vb.net:
Private Sub HandleKeyEvent(sender As Object, e As Renci.SshNet.Common.AuthenticationPromptEventArgs)
For Each prompt As Renci.SshNet.Common.AuthenticationPrompt In e.Prompts
If prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) <> -1 Then
prompt.Response = Password
End If
Next
End Sub
但
KIAuthMeth.AuthenticationPrompt += ...
不認可。我卡住了。
任何想法?我是否正確?
是什麼意思* 「無法識別」 *? SSH.NET 2014.4.6-beta2中有'KeyboardInteractiveAuthenticationMethod.AuthenticationPrompt'。 –
好吧,你不知道如何在VB.NET中分配一個事件處理程序,對吧? –
我不知道如何分配一個事件,但現在我知道;)謝謝 –