coder/docs/ides/gateway.md

7.2 KiB

JetBrains Gateway

JetBrains Gateway is a compact desktop app that allows you to work remotely with a JetBrains IDE without even downloading one. See JetBrains' website to learn about and Gateway.

Gateway can connect to a Coder workspace by using Coder's Gateway plugin or manually setting up an SSH connection.

Using Coder's JetBrains Gateway Plugin

If you experience problems, please create a GitHub issue or share in our Discord channel.

  1. Install Gateway

  2. Open Gateway and click the Coder icon to install the Coder plugin.

  3. Click the "Coder" icon under Install More Providers at the bottom of the Gateway home screen

  4. Click "Connect to Coder" at the top of the Gateway home screen to launch the plugin

    Gateway Connect to Coder

  5. Enter your Coder deployment's Access Url and click "Connect" then paste the Session Token and click "OK"

    Gateway Session Token

  6. Click the "+" icon to open a browser and go to the templates page in your Coder deployment to create a workspace

  7. If a workspace already exists but is stopped, click the green arrow to start the workspace

  8. Once the workspace status says Running, click "Select IDE and Project"

    Gateway IDE List

  9. Select the JetBrains IDE for your project and the project directory then click "Start IDE and connect" Gateway Select IDE

    Gateway IDE Opened

Note the JetBrains IDE is remotely installed into ~/.cache/JetBrains/RemoteDev/dist

Update a Coder plugin version

  1. Click the gear icon at the bottom left of the Gateway home screen and then "Settings"

  2. In the Marketplace tab within Plugins, type Coder and if a newer plugin release is available, click "Update" and "OK"

    Gateway Settings and Marketplace

Configuring the Gateway plugin to use internal certificates

When attempting to connect to a Coder deployment that uses internally signed certificates, you may receive the following error in Gateway:

Failed to configure connection to https://coder.internal.enterprise/: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

To resolve this issue, you will need to add Coder's certificate to the Java trust store present on your local machine. Here is the default location of the trust store for each OS:

# Linux
<Gateway installation directory>/jbr/lib/security/cacerts

# macOS
<Gateway installation directory>/jbr/lib/security/cacerts
/Library/Application Support/JetBrains/Toolbox/apps/JetBrainsGateway/ch-0/<app-id>/JetBrains Gateway.app/Contents/jbr/Contents/Home/lib/security/cacerts # Path for Toolbox installation

# Windows
C:\Program Files (x86)\<Gateway installation directory>\jre\lib\security\cacerts
%USERPROFILE%\AppData\Local\JetBrains\Toolbox\bin\jre\lib\security\cacerts # Path for Toolbox installation

To add the certificate to the keystore, you can use the keytool utility that ships with Java:

keytool -import -alias coder -file <certificate> -keystore /path/to/trust/store

You can use keytool that ships with the JetBrains Gateway installation. Windows example:

& 'C:\Program Files\JetBrains\JetBrains Gateway <version>/jbr/bin/keytool.exe' 'C:\Program Files\JetBrains\JetBrains Gateway <version>/jre/lib/security/cacerts' -import -alias coder -file <cert>

# command for Toolbox installation
& '%USERPROFILE%\AppData\Local\JetBrains\Toolbox\apps\Gateway\ch-0\<VERSION>\jbr\bin\keytool.exe' '%USERPROFILE%\AppData\Local\JetBrains\Toolbox\bin\jre\lib\security\cacerts' -import -alias coder -file <cert>

macOS example:

keytool -import -alias coder -file cacert.pem -keystore /Applications/JetBrains\ Gateway.app/Contents/jbr/Contents/Home/lib/security/cacerts

Manually Configuring A JetBrains Gateway Connection

This is in lieu of using Coder's Gateway plugin which automatically performs these steps.

  1. Install Gateway

  2. Configure the coder CLI

  3. Open Gateway, make sure "SSH" is selected under "Remote Development"

  4. Click "New Connection"

    Gateway Home

  5. In the resulting dialog, click the gear icon to the right of "Connection:"

    Gateway New Connection

  6. Hit the "+" button to add a new SSH connection

    Gateway Add Connection

  7. For the Host, enter coder.<workspace name>

  8. For the Port, enter 22 (this is ignored by Coder)

  9. For the Username, enter your workspace username

  10. For the Authentication Type, select "OpenSSH config and authentication agent"

  11. Make sure the checkbox for "Parse config file ~/.ssh/config" is checked.

  12. Click "Test Connection" to validate these settings.

  13. Click "OK"

    Gateway SSH Configuration

  14. Select the connection you just added

    Gateway Welcome

  15. Click "Check Connection and Continue"

    Gateway Continue

  16. Select the JetBrains IDE for your project and the project directory. SSH into your server to create a directory or check out code if you haven't already.

    Gateway Choose IDE

    Note the JetBrains IDE is remotely installed into ~/. cache/JetBrains/RemoteDev/dist

  17. Click "Download and Start IDE" to connect.

    Gateway IDE Opened

Using an existing JetBrains installation in the workspace

If you would like to use an existing JetBrains IDE in a Coder workspace (or you are air-gapped, and cannot reach jetbrains.com), run the following script in the JetBrains IDE directory to point the default Gateway directory to the IDE directory. This step must be done before configuring Gateway.

cd /opt/idea/bin
./remote-dev-server.sh registerBackendLocationForGateway

Gateway only works with paid versions of JetBrains IDEs so the script will not be located in the bin directory of JetBrains Community editions.

Here is the JetBrains article explaining this IDE specification.

JetBrains Gateway in an offline environment

In networks that restrict access to the internet, you will need to leverage the JetBrains Client Installer to download and save the IDE clients locally. Please see the JetBrains documentation for more information.