How to set up SSH for ECE linux "the right way". No VPN is required to SSH into ECE linux. Notably, with this setup:
- Skip
eceterm
completely and go directly toeceubuntu/ecetesla
- you only need to type the SSH command ONCE (and enter your password ONCE). - Configure VS Code to work over SSH. Edit remote files while maintaining your VS Code features like Intellisense, syntax highlighting, themes, etc.
Skip to the bottom of the document for a summary (TL;DR).
This step allows you connect directly to eceubuntu/ecetesla, skipping eceterm completely.
We do this by modifying your SSH config file to use ProxyJump
(or ProxyCommand
on Windows)
On your local machine, open the file ~/.ssh/config
(if it doesn't exist yet, create it).
Add the following to the file. Replace <your UW username>
with your username
Host eceterm
HostName %h.uwaterloo.ca
User <your UW username>
Host eceubuntu1 eceubuntu2 eceubuntu4 ecetesla0 ecetesla1 ecetesla2 ecetesla3
HostName %h.uwaterloo.ca
User <your UW username>
ProxyJump eceterm
On your local machine, open the file C:/Users/<username>/.ssh/config
(if it doesn't exist yet, create it).
Add the following to the file. Replace <your UW username>
with your username
Host eceterm
HostName %h.uwaterloo.ca
User <your UW username>
Host eceubuntu1 eceubuntu2 eceubuntu4 ecetesla0 ecetesla1 ecetesla2 ecetesla3
HostName %h.uwaterloo.ca
User <your UW username>
ProxyCommand C:\Windows\System32\OpenSSH\ssh.exe -W %h:%p eceterm
Now you should be able to connect to ECE servers using commands like:
ssh eceubuntu1
, ssh ecetesla0
, etc.
But you'll still need to enter your password and Duo 2FA. The next step shows you how to skip this.
Covers SSH key generation, SSH authorized key setup.
The first step is to generate SSH private/public pair. If you've already done this before, skip this step.
Run
ssh-keygen -t rsa
Create a password to protect this key if you'd like (optional).
I HIGHLY recommend naming the files something meaningful (ie. ecelinux
) rather than id_rsa
. You should still save it under the path ~/.ssh
.
Again, skip this step if you've already done this before. Essentially, you need to copy the public key you generated into the file ~/.ssh/authorized_keys
on the remote ecelinux machine.
On macOS and Windows Subsystem for Linux, you can use ssh-copy-id
to quickly copy over your SSH credentials and authorize yourself.
ssh-copy-id eceterm
(On Windows, first use bash
to get into WSL)
- Copy your SSH public key to eceterm (replace
id_rsa
with your file name andusername
with your username):
scp ~/.ssh/id_rsa.pub username@eceterm
- Connect to the remote machine, ie. over SSH (the password will be your UW password):
ssh yourusername@eceterm
- If the folder and file
~/.ssh/authorized_keys
does not exist yet, create the folder and file. Then, append your public key to the end of the file.
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
- Delete the public key that you copied from your remote machine:
rm ~/id_rsa.pub
Test it out by disconnecting from the remote machine, then connect again using ssh eceterm
This time, you shouldn't have to enter your password or Duo 2FA
If you followed these steps correctly, you should now be able to SSH directly to eceubuntu. For example, ssh eceubuntu1
should work directly!
If you aren't comfortable with terminal-based editors like Vim, a great way to work on ECE linux is through VS Code's Remote Development extension. It allows you to use VS Code on any remote machine, while maintaining all your preferences and themes!
In order to do this, you must have set up SSH correctly, especially the automatic ProxyJump
. If you haven't, please follow those steps first!
If don't have VS Code, install it (Google is your friend). Then, install the Remote Development
extension pack by Microsoft.
Use the extension to connect to eceubuntu through VS Code! Yep, it's that easy.
Command Palette > Remote-SSH: Connect to Host... > eceubuntu*
or press the button on the bottom left corner:
Assuming your SSH config is set up correctly, this should work. If it doesn't work, check you SSH config. If it still doesn't work, sorry :(
Note for macOS: Some people may run into an issue where it fails to set up the VS Code server on the ECE machines. This is due to the setup script trying to use bash
on the ECE machines, but their default shell is tcsh
. To get around this, ssh onto eceterm
and run the command chsh -s /bin/bash
and that should change your default shell on the ECE machine to be bash.
You'll need to install extensions remotely on the ECE linux servers. Simply do so by installing extensions after you've Remote-SSH'ed in. For example, you might want to install the Java development pack, if you're working with Java.
Here are some tips:
- Install Intellisense extensions as needed on the remote instance of VS Code. For example, VS Code is great for Java with the
Java
extension pack! - After opening a Java project, in the sidebar, go to
Java Dependencies > Referenced Libraries
and add appropriate paths. For example, this might be/lib
,/gen-java
, etc.
Generate SSH key pair. Add public to AuthorizedKeys
on the ECE server. Add the following to your local ~/.ssh/config
file:
Host eceterm eceterm1 eceterm2
HostName %h.uwaterloo.ca
User jzxhuang
ForwardAgent yes
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/ecelinux
Host eceubuntu1 eceubuntu2 eceubuntu4 ecetesla0 ecetesla1 ecetesla2 ecetesla3
HostName %h.uwaterloo.ca
User jzxhuang
ProxyJump eceterm
ForwardAgent yes
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/ecelinux
To use VS Code over SSH, install the Remote Development
extension pack. You can use it to directly edit remote files in VS Code (Command Palette > Remote-SSH: Connect to Host... > eceubuntu*
).
An alternative to this workflow is to mount the remote drive SSHFS. I found this option to be slow and doesn't meet all my needs, but it's another valid option!
I hope you found this useful. Share it with your classmates and star/bookmark this for your own convenience!