B4X
B4X
Authenticate an SSH Tunnel with a Password
See more Socket/SSL/TLS Examples
Demonstrates Socket.SshAuthenticatePw, which authenticates an SSH tunnel session using a login and password. Call SshOpenTunnel first.
Background. Authenticate before opening forwarded channels. The password should come from a secure source and never be logged; public-key authentication is often preferred.
Chilkat B4X Downloads
Dim success As Boolean = False
Dim socket As ChilkatSocket
socket.Initialize("socket")
success = socket.SshOpenTunnel("ssh.example.com", 22)
If success = False Then
Log(socket.LastErrorText)
Return
End If
' Authenticate the SSH tunnel session with a login and password.
' The SSH password should come from a secure source rather than being hard-coded.
Dim sshPassword As String = "mySshPassword"
success = socket.SshAuthenticatePw("sshUser", sshPassword)
If success = False Then
Log(socket.LastErrorText)
Return
End If
Log("SSH authentication succeeded.")