Secure Shell (SSH) connector methods

  • Release version: Yokohama
  • Updated January 30, 2025
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Secure Shell (SSH) connector methods

    The Secure Shell (SSH) connector methods in ServiceNow Yokohama release allow you to establish SSH connections, execute commands remotely, and disconnect sessions. These methods enable secure and automated interaction with remote machines via SSH, supporting multiple authentication types.

    Show full answer Show less

    Connect Method

    This method establishes an SSH connection to a remote server. You need to provide details such as the host name or IP address, username, password, and optionally the port number (default 22). Authentication types supported include Password (default), KeyboardInteractive, and KeyFileAuthentication.

    Key parameters include:

    • HostName: Remote server address.
    • Username: SSH account username.
    • Password: Secure string password, which can be encoded with the SecureStringEncode component.
    • CreateShell: Boolean to create a shell stream for command execution (default True).
    • KeyboardInteractiveAuth: Used when KeyboardInteractive authentication is selected.
    • KeyFilepath and Passphrase: For private key authentication.

    RunCommand Method

    After connecting, use this method to run shell or executable commands on the remote SSH server.

    Key parameters:

    • Command: The command to execute (e.g., echo hello).
    • Timeout: Optional maximum wait time in seconds for command output (default 30 seconds).

    The output of the command is returned as a string, allowing you to use or verify command results within your workflows.

    Disconnect Method

    Once your commands have executed, use the Disconnect method to safely close the SSH connection and release resources.

    Practical Use for ServiceNow Customers

    These SSH connector methods enable ServiceNow customers to automate remote server management and command execution securely within ServiceNow workflows. They support different authentication mechanisms to fit various security requirements. By integrating SSH operations into ServiceNow automations, administrators can manage remote infrastructure more efficiently and securely.

    The Secure Shell (SSH) connector methods establish an SSH connection, execute commands over the established connection, and disconnect the session.

    Connect

    Establishes an SSH connection. Provide the information required to connect to a remote machine.

    Select the settings icon (Settings icon) to choose the authentication type.

    Supported authentication types are Password, KeyboardInteractive, and KeyFileAuthentication.The authentication type configuration window displaying the Password, KeyboardInteractive, and KeyFileAuthentication as authentication types.

    Password is the default authentication type.

    Table 1. Connect method parameters
    Parameter Description Data Port Type Data type
    HostName Host name of the remote server or IP address. Data In String
    Username User name of the SSH account. Data In String
    Password

    Secure string representation of the password. Password of the SSH account.

    You can use the SecureStringEncode component to encode the secure string password as mentioned in the following example. For more information, see Use the SecureStringEncode component.
    Figure 1. Connect method with Password parameter
    SecureStringEncode component is connected to the Connect method to pass the encoded password.

    After you perform this task, you can connect to the remote server.

    Data In SecureString
    Port Optional. The port number for the SSH connection. Default value is 22. Data In Integer
    CreateShell Optional. If True, a shell stream is created on successful connection. Any command that is executing on this connection uses the shell.

    If False, any command that is executing on this connection does not the shell.

    Default value is True.

    Data In Boolean
    KeyboardInteractiveAuth Password as a challenge.

    If True, the server prompts the client for password to verify the user's identity. Value provided in the password parameter is shared as a response from client.

    This parameter appears only when KeyboardInteractive is selected from the Authentication Type.

    Data In Boolean
    KeyFilepath Path of the private key.

    This parameter appears only when KeyFileAuthentication is selected from the Authentication Type.

    Data In String
    Passphrase Optional. If private key is encrypted using Passphrase, same value is provided inside the Passphrase parameter to use the private key.

    This parameter appears only when KeyFileAuthentication is selected from the Authentication Type.

    Data In String

    RunCommand

    After establishing an SSH connection, execute commands over the established connection using the RunCommand method.

    Table 2. RunCommand method parameters
    Parameter Description Data Port Type Data type
    Command Commands that must be executed on the remote SSH server, such as messages or scripts, can be valid shell commands or executable commands that the remote server can understand.

    For example, echo hello.

    Figure 2. RunCommand method - Command parameter
    Command entered as "echo hello" in the Command parameter RunCommand method
    Data In String
    Timeout Optional. The parameter that specifies the maximum time (in seconds) to wait for the command's output from the SSH server when using an interactive shell.

    Default value is 30.

    Data In Integer
    Return The result of the executed command.

    For example, after executing the automation, in the Data Preview of Return parameter, "hello" is displayed.

    Figure 3. Return parameter of RunCommand method
    Data previews as hello, after the command is executed
    Data Out String

    Disconnect

    After executing commands, disconnect the established connection using the Disconnect method.

    The following example shows the entire automation after adding the Disconnect method.

    Figure 4. Disconnect method
    SSH connector automation workflow example.