How to use JetBrains Gateway with Workshop

JetBrains Gateway allows you to connect to remote development environments while using your favorite JetBrains IDEs (IntelliJ IDEA, PyCharm, and so on). A workshop can serve as the remote development target for JetBrains Gateway, letting you use your favorite JetBrains IDEs against Workshop.

Prerequisites

  • Download and install JetBrains Gateway on your host system.

  • Create a workshop or choose an existing one.

  • Generate an SSH key pair if you don’t have one already:

    $ ssh-keygen -t rsa -b 4096 -C "<your_email@example.com>"
    

Configure your workshop

Configure your workshop to accept SSH connections by adding a plug, a slot, and an action to upload your public SSH key.

  1. First, add a tunnel interface plug for the system SDK in the workshop definition:

    workshop.yaml
    sdks:
      - name: system
        plugs:
          gateway:
            interface: tunnel
            endpoint: 2200
    

    This exposes port 2200 on the host that you will use in JetBrains Gateway.

  2. Next, add a corresponding slot; you can graft it onto an existing SDK or add it with sketching:

  1. Add an action to upload your public SSH key to the workshop:

    workshop.yaml
    actions:
      upload-public-key: |
        PUBLIC_KEY="$1"
        if [ -z "${PUBLIC_KEY}" ]; then
          echo 'cannot upload public key: pass the public key as the argument' 1>&2
          exit 1
        fi
        echo "${PUBLIC_KEY}" >> $HOME/.ssh/authorized_keys
    

    This appends your public SSH key to the list of authorized keys for the workshop user.

  2. Refresh the workshop to apply the changes if you haven’t done so already:

    $ workshop refresh
    
  3. Use the action to upload your public SSH key to the workshop, for example:

    $ workshop run dev upload-public-key "$(cat ~/.ssh/id_rsa.pub)"
    

The workshop is now ready to accept SSH connections.

Connect with Gateway

  1. Open JetBrains Gateway.

  2. Create a new SSH connection using these values:

    • Username: workshop

    • Host: localhost

    • Port: 2200

    • Specify private key: Your private SSH key counterpart to the public key you uploaded earlier.

  3. Click Check connection and continue.

  4. At the next screen, select your preferred JetBrains IDE version, e.g. PyCharm.

  5. Under Installation options, choose Customize installation path and set it to a path under /project/, e.g. /project/pycharm/; this ensures the IDE has enough disk space.

  6. For Project directory, choose /project/.

  7. Click Start IDE and connect, then wait for the IDE to install and launch; this may take a few minutes. After the IDE starts, log in and proceed as usual.

Your JetBrains IDE will now run remotely in the workshop while providing a native desktop experience.

See also

Explanation:

Reference: