Sample code for 30+ languages & platforms
PowerBuilder

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

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Socket
string ls_SshPassword

li_Success = 0

loo_Socket = create oleobject
li_rc = loo_Socket.ConnectToNewObject("Chilkat.Socket")
if li_rc < 0 then
    destroy loo_Socket
    MessageBox("Error","Connecting to COM object failed")
    return
end if

li_Success = loo_Socket.SshOpenTunnel("ssh.example.com",22)
if li_Success = 0 then
    Write-Debug loo_Socket.LastErrorText
    destroy loo_Socket
    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.
ls_SshPassword = "mySshPassword"
li_Success = loo_Socket.SshAuthenticatePw("sshUser",ls_SshPassword)
if li_Success = 0 then
    Write-Debug loo_Socket.LastErrorText
    destroy loo_Socket
    return
end if

Write-Debug "SSH authentication succeeded."


destroy loo_Socket