Sample code for 30+ languages & platforms
DataFlex

Send an SSH IGNORE Message

See more SSH Examples

Demonstrates the Chilkat Ssh.SendIgnore method, which sends an SSH IGNORE message. It takes no arguments. The server does not reply, but a successful send helps confirm the connection is still writable. No channel is required.

Background: The SSH IGNORE message is discarded by the peer by design; its usefulness is as a lightweight keep-alive or liveness probe. Because it exercises the actual write path, a successful SendIgnore is stronger evidence than CheckConnection that the link is still usable, without side effects on any channel.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoSsh
    Integer iSshPort
    String sPassword
    String sTemp1

    Move False To iSuccess

    //  Demonstrates the Ssh.SendIgnore method, which sends an SSH IGNORE message.  It takes no
    //  arguments.  The server does not reply, but a successful send helps confirm the connection is
    //  still writable.  No channel is required.

    Get Create (RefClass(cComChilkatSsh)) To hoSsh
    If (Not(IsComObjectCreated(hoSsh))) Begin
        Send CreateComObject of hoSsh
    End

    //  Connect to the SSH server.  Port 22 is the usual SSH port.
    Move 22 To iSshPort
    Get ComConnect Of hoSsh "ssh.example.com" iSshPort To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoSsh 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 hoSsh "mySshLogin" sPassword To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoSsh To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    //  Send an IGNORE message to verify the connection is still writable.
    Get ComSendIgnore Of hoSsh To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoSsh To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "IGNORE message sent."

    Send ComDisconnect To hoSsh


End_Procedure