Sample code for 30+ languages & platforms
PowerBuilder

SSH using SOCKS Proxy

See more SSH Examples

Demonstrates how to connect to an SSH server through a SOCKS4 or SOCKS5 proxy.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Ssh
string ls_Hostname
integer li_Port

li_Success = 0

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

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

// To use a SOCKS4 or SOCKS5 proxy, simply set the following
// properties prior to connecting:
// The SOCKS hostname may be a domain name or 
// IP address:
loo_Ssh.SocksHostname = "www.mysocksproxyserver.com"
loo_Ssh.SocksPort = 1080
loo_Ssh.SocksUsername = "myProxyLogin"
loo_Ssh.SocksPassword = "myProxyPassword"

// Set the SOCKS version to 4 or 5 based on the version
// of the SOCKS proxy server:
loo_Ssh.SocksVersion = 5

// Note: SOCKS4 servers only support usernames without passwords.
// SOCKS5 servers support full login/password authentication.

// Connect to an SSH server via a SOCKS proxy:

// Hostname may be an IP address or hostname:
ls_Hostname = "192.168.1.108"
li_Port = 22

li_Success = loo_Ssh.Connect(ls_Hostname,li_Port)
if li_Success <> 1 then
    Write-Debug loo_Ssh.LastErrorText
    destroy loo_Ssh
    return
end if

// Your application is now connected to an SSH server 
// through a SOCKS4 or SOCKS5 proxy. 
// ..


destroy loo_Ssh