RubyMine 2021.2 Help

SSH

RubyMine allows you to work with remote machines using SSH. You can create predefined SSH configurations and use them to run remote SSH sessions, configure a remote Ruby interpreter, or connect to databases.

Set up SSH

Before working with remote machines using SSH, make sure that SSH access is enabled on a remote server. You can use several authentication methods, for example:

  • Use a remote host's username and password for authentication.

  • Generate the SSH public/private key pair on your local machine and add the public key to the remote host.

  • If the SSH public/private key pair exists on your local machine and the public key is uploaded to the remote host, you can add the private key to the ssh-agent.

Add an SSH configuration

You can create the predefined SSH configurations and reuse them within a specific project or across all your projects. To create a new SSH configuration, follow the steps below:

  1. Press Ctrl+Alt+S to open the IDE settings and select Tools | SSH Configurations.
  2. Click the Add button to add a new configuration.

  3. If you do not want to share the configuration between projects, make sure that the Visible only for this project option is enabled.

  4. Specify the required parameters depending on the Authentication type.

    SSH configuration settings
    • Host/Port: The hostname/IP address and port used to connect to a remote machine.

    • User name: The username used to authenticate on a remote machine.

    • Authentication type: In this field, select the Password value to authenticate a user with a password.

    • Password: Specify a password used to access a remote machine.

    • Host/Port: The hostname/IP address and port used to connect to a remote machine.

    • User name: The username used to authenticate on a remote machine.

    • Authentication type: In this field, select Key pair.

    • Private key file: Specify a path to a private key file stored on a local machine.

    • Passphrase (optional): Specify a passphrase used for the specified private key.

    • Host/Port: The hostname/IP address and port used to connect to a remote machine.

    • User name: The username used to authenticate on a remote machine.

    • Authentication type: In this field, select OpenSSH config and authentication agent to use ssh-agent running on a local machine.

  5. Configure connection parameters.

    • Send keep alive messages every: Send regular packets to keep the SSH connection active. Without regular messages, the remote server might close the connection. Set the message period in seconds.

    • Strict host key checking: Specify how to handle new and changed host keys.

      • Yes: Never add new host keys to the user's known_hosts file and never allow connections to hosts with changed host keys.

      • Accept New: Always add new host keys to the user's known_hosts file but never allow connections to hosts with changed host keys.

      • No: Always add new host keys to the user's known_hosts file and allow connections to hosts with changed host keys.

      • Ask: Add new host keys to the user's known_hosts file only after confirmation and never allow connections to hosts with changed host keys. This is the default behavior.

    • Hash hosts in known_hosts file: Store new host records in hash format.

  6. Click OK.

Supported OpenSSH directives

Start an SSH session

To start an SSH session on a remote host, follow the steps below:

Start an SSH session

  1. From the main menu, choose Tools | Start SSH Session.

  2. If you already have existing SSH configurations or running Vagrant instances, select the desired one in the invoked popup.

    Select host to connect

    You can also choose Edit credentials to specify credentials manually.

  3. (Optional) If you selected Edit credentials, specify the required parameters depending on the Authentication type, as described in Add an SSH configuration.

    SSH Session dialog
  4. A new SSH session is opened in a separate tab.

    SSH terminal

    To close the SSH session, click the Close button on the terminal toolbar or right-click the current session tab and select Close Tab from the context menu.

Configure SSH terminal setting

You can configure the following SSH terminal settings on the Tools | SSH Terminal page of the Settings/Preferences dialog Ctrl+Alt+S:

  • Connection settings

    Choose one of the following:

    • Current Vagrant: Select this option to connect to the running Vagrant instance.

    • SSH configuration: Select the existing SSH configuration to connect it to every time, or choose Select SSH configuration on every run to invoke the popup with available servers when executing Tools | Start SSH Session.

  • Default encoding

    Select the desired encoding to be used in the SSH terminal.

Configure a remote interpreter using SSH

RubyMine allows you to configure a remote Ruby interpreter by using SSH access and work with applications deployed on a remote server. This can be useful to run or debug a remote application, perform tests, and so on. Make sure that the following prerequisites are met for a remote server before configuring a remote interpreter:

You can now follow the steps below to configure a remote interpreter using SSH:

  1. Open the Settings/Preferences dialog Ctrl+Alt+S, go to the Language & Frameworks | Ruby SDK and Gems page.

  2. Click the Add icon and select New remote… in the drop-down:

    New remote

  3. In the invoked dialog, select SSH and specify the following settings:

    Configure remote ruby interpreter: SSH
    • SSH configuration: Select the existing SSH configuration or click the ellipsis button and create a new one.

    • Ruby or version manager path: Here you should specify the path to the Ruby interpreter or the version manager executable.

    After you have specified all the settings, click OK.

  4. (Optional) If you specified a path to the version manager executable in the previous dialog, RubyMine suggests selecting the Ruby interpreter used to run a remote application.

    Select distribution

  5. Select the added SDK in the Ruby SDK and Gems page.

    Select remote SDK
  6. Specify mappings between files of a local and remote project. To do this, click the Edit Path Mappings Edit Path Mappings button. In the Edit Project Path Mappings dialog, specify the local and remote project root paths.

    Edit Project Path Mappings
Last modified: 19 May 2021