Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loSocket
LOCAL lcSshPassword

lnSuccess = 0

loSocket = CreateObject('Chilkat.Socket')

lnSuccess = loSocket.SshOpenTunnel("ssh.example.com",22)
IF (lnSuccess = 0) THEN
    ? loSocket.LastErrorText
    RELEASE loSocket
    CANCEL
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"
lnSuccess = loSocket.SshAuthenticatePw("sshUser",lcSshPassword)
IF (lnSuccess = 0) THEN
    ? loSocket.LastErrorText
    RELEASE loSocket
    CANCEL
ENDIF

? "SSH authentication succeeded."

RELEASE loSocket