Sample code for 30+ languages & platforms
DataFlex

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

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoTunnel
    Integer iSshPort
    String sPassword
    Integer iListenPort
    Boolean iWaitForThreadExit
    String sTemp1

    Move False To iSuccess

    //  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.

    Get Create (RefClass(cComChilkatSshTunnel)) To hoTunnel
    If (Not(IsComObjectCreated(hoTunnel))) Begin
        Send CreateComObject of hoTunnel
    End

    //  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.
    Set ComUncommonOptions Of hoTunnel To "NoKeepAliveIgnoreMsg,no-weak-mac-algs"

    Set ComDestHostname Of hoTunnel To "db.internal.example.com"
    Set ComDestPort Of hoTunnel To 5432

    Move 22 To iSshPort
    Get ComConnect Of hoTunnel "ssh.example.com" iSshPort To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoTunnel To sTemp1
        Showln sTemp1
        Procedure_Return
    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.
    Move "mySshPassword" To sPassword

    Get ComAuthenticatePw Of hoTunnel "mySshLogin" sPassword To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoTunnel To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Move 1080 To iListenPort
    Get ComBeginAccepting Of hoTunnel iListenPort To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoTunnel To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Tunnel established."

    Move True To iWaitForThreadExit
    Get ComCloseTunnel Of hoTunnel iWaitForThreadExit To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoTunnel To sTemp1
        Showln sTemp1
        Procedure_Return
    End



End_Procedure