Delphi DLL
Delphi DLL
SSH Tunnel Uncommon Options
See more SSH Tunnel Examples
Demonstrates the UncommonOptions property, which enables optional behavior for uncommon requirements. The default is an empty string; provide a comma-separated list of keywords to enable more than one option. Available keywords are listed in the reference documentation.
Background: This is a catch-all for narrow workarounds that do not warrant their own properties — forcing a specific signature algorithm, disabling the periodic keep-alive, removing weak MACs, bypassing a VPN on Android, and so on. Most applications never set it. When you do, it is usually to satisfy a particular server's quirk or a specific security requirement, and the exact keyword matters, so consult the documented list rather than guessing.
Chilkat Delphi DLL Downloads
var
success: Boolean;
tunnel: HCkSshTunnel;
sshPort: Integer;
password: PWideChar;
listenPort: Integer;
waitForThreadExit: Boolean;
begin
success := False;
// Demonstrates the SshTunnel.UncommonOptions property, which enables optional behavior for
// uncommon requirements. The default is an empty string, appropriate for most applications.
// Provide a comma-separated list of keywords to enable more than one option.
tunnel := CkSshTunnel_Create();
// For example, disable the periodic keep-alive ignore message and remove weak MAC algorithms
// from those offered. Available keywords are listed in the reference documentation.
CkSshTunnel_putUncommonOptions(tunnel,'NoKeepAliveIgnoreMsg,no-weak-mac-algs');
CkSshTunnel_putDestHostname(tunnel,'db.internal.example.com');
CkSshTunnel_putDestPort(tunnel,5432);
sshPort := 22;
success := CkSshTunnel_Connect(tunnel,'ssh.example.com',sshPort);
if (success = False) then
begin
Memo1.Lines.Add(CkSshTunnel__lastErrorText(tunnel));
Exit;
end;
// Normally you would not hard-code the password in source. You should instead obtain it
// from an interactive prompt, environment variable, or a secrets vault.
password := 'mySshPassword';
success := CkSshTunnel_AuthenticatePw(tunnel,'mySshLogin',password);
if (success = False) then
begin
Memo1.Lines.Add(CkSshTunnel__lastErrorText(tunnel));
Exit;
end;
listenPort := 1080;
success := CkSshTunnel_BeginAccepting(tunnel,listenPort);
if (success = False) then
begin
Memo1.Lines.Add(CkSshTunnel__lastErrorText(tunnel));
Exit;
end;
Memo1.Lines.Add('Tunnel established.');
waitForThreadExit := True;
success := CkSshTunnel_CloseTunnel(tunnel,waitForThreadExit);
if (success = False) then
begin
Memo1.Lines.Add(CkSshTunnel__lastErrorText(tunnel));
Exit;
end;
CkSshTunnel_Dispose(tunnel);