Skip to content

Instantly share code, notes, and snippets.

@maxwellamaral
Forked from bubba-h57/instructions.md
Created August 2, 2022 23:52
Show Gist options
  • Save maxwellamaral/4d47675089c9f72d648d4a29f4cabcb3 to your computer and use it in GitHub Desktop.
Save maxwellamaral/4d47675089c9f72d648d4a29f4cabcb3 to your computer and use it in GitHub Desktop.
Configuring Jetbrains Gateway and WSL

Step 1: SSH Daemon

In your WSL instance, re-install OpenSSH server as follows.

sudo apt remove --purge openssh-server
sudo apt install openssh-server

Edit /etc/ssh/sshd_config (e.g. sudo vi /etc/ssh/sshd_config) and add the following lines to the bottom of the file. Ensure you replace WSL_ACCOUNT_NAME with your WSL2 account name.

PasswordAuthentication yes
AllowUsers WSL_ACCOUNT_NAME 

(Optional) For security, allow only specific IP addresses to login. E.g. to allow 192.30.118.x and 194.57.240.32 only, do as follows. edit as follows.

Edit /etc/hosts.deny (e.g. sudo vi /etc/hosts.deny). and add the floowing line:

sshd: 192.30.118.0/24 194.57.240.32

Restart the SSH server.

sudo service ssh --full-restart

Allow SSH server to start without password. Run sudo visudo and find the %sudo ALL=(ALL:ALL) ALL. Immediately below that line, add this line.

%sudo ALL=NOPASSWD: /etc/init.d/ssh

Step 2: Auto Start SSH Daemon

WSL2 will not start ssh up for you on each boot. You will need to configure a windows Task, scheduled to run everytime the system boots, to start up SSH inside WSL on boot. Google it, or check out this StackExchange answer.

Step 3: Resolve WSL Hostname

Microsoft hasn't built this in for you. Fortunately, Shane did. Install and setup the go-wsl2-host service. That will then handle the DNS resolution for your WSL instance.

Step 4. Jetbrains Gateway

Download and install Jetbrains Gateway. Once you have it running, configure an SSH connection to your WSL instance, and map a project directory. Choose the Jetbrains IDE you want to use and go to it. The gateway will download and install an agent (headless client) that will run locally within the WSL instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment