● 修改 OpenSSH 的設定檔 /usr/local/etc/ssh/sshd_config
把 #PasswordAuthentication no 改成 PasswordAuthentication yes
重新啟動服務
# service openssh restart
● 範例程式碼
Imports Renci.SshNet Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim _host = "192.168.23.191" Dim _username As String = "jimmy" Dim _password As String = "123" Dim _port As Integer = 22 Dim a(0) As AuthenticationMethod a(0) = New PasswordAuthenticationMethod(_username, _password) Dim conInfo As ConnectionInfo = New ConnectionInfo(_host, _port, _username, a(0)) Dim _SshClient As SshClient = New SshClient(conInfo) _SshClient.Connect() Dim _sshcommand As SshCommand = _SshClient.CreateCommand("echo 2 > /tmp/2") _sshcommand.Execute() End Sub