Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oSocket
LOCAL cSshPassword

nSuccess := 0

oSocket := CreateObject("Chilkat.Socket")

nSuccess := oSocket:SshOpenTunnel("ssh.example.com", 22)
IF (nSuccess == 0)
    ? oSocket:LastErrorText
    oSocket:destroy()
    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.
cSshPassword := "mySshPassword"
nSuccess := oSocket:SshAuthenticatePw("sshUser", cSshPassword)
IF (nSuccess == 0)
    ? oSocket:LastErrorText
    oSocket:destroy()
    RETURN
ENDIF

? "SSH authentication succeeded."

oSocket:destroy()