Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

loSocket = createobject("CkSocket")

llSuccess = loSocket.SshOpenTunnel("ssh.example.com",22)
if (llSuccess = .F.) then
    ? loSocket.LastErrorText
    release loSocket
    return
endif

//  Authenticate the SSH tunnel session with a login and password.
//  The SSH password should come from a secure source rather than being hard-coded.
lcSshPassword = "mySshPassword"
llSuccess = loSocket.SshAuthenticatePw("sshUser",lcSshPassword)
if (llSuccess = .F.) then
    ? loSocket.LastErrorText
    release loSocket
    return
endif

? "SSH authentication succeeded."


release loSocket