DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoSocket
String sSshPassword
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatSocket)) To hoSocket
If (Not(IsComObjectCreated(hoSocket))) Begin
Send CreateComObject of hoSocket
End
Get ComSshOpenTunnel Of hoSocket "ssh.example.com" 22 To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoSocket To sTemp1
Showln sTemp1
Procedure_Return
End
// Authenticate the SSH tunnel session with a login and password.
// The SSH password should come from a secure source rather than being hard-coded.
Move "mySshPassword" To sSshPassword
Get ComSshAuthenticatePw Of hoSocket "sshUser" sSshPassword To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoSocket To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "SSH authentication succeeded."
End_Procedure