Secure Shell (SSH)¶
1. Getting started 🧰¶
On most operating systems (certainly on Linux based systems including MacOS), SSH is installed by default. Verify that it is installed:
- check if SSH exists, run:
If the output is "ssh not found", then you need to install SSH. ❌ \ If the output is a path (example: ""/usr/bin/ssh"), then SSH is already installed. ✅
which ssh - check if the SSH key generator exists, run:
which ssh-keygen
2. Set up SSH keys on your computer¶
⚠️ These steps need to be done only once on each machine you use.
- Open a command line program/terminal locally on your computer.
- If you are using Windows, open the PowerShell.
- If you are running MacOS, open the Terminal.
-
If you are using Linux, open the Terminal.
-
Check if you have already generated SSH keys on your computer. If you have, you can skip this How-To.
- Change to your home directory.
(Note: If you opened a fresh terminal, you are probably already there.)
cd ~ -
List file in directory
.sshIf you see files of the patternls .sshid_*andid_*.pub, for instance,id_ed25519andid_ed25519.pub, then you can skip the next step. -
Generate a public-private pair of SSH keys for your computer.
- In most terminals, run
ssh-keygen -t ed25519 - In Windows PowerShell, you may need to run
ssh-keygen.exe -t ed25519 - Press Enter key to accept the suggested file location
(usually
<your_home_directory>/.ssh/id_rsa). - It is recommended that you invent and enter a password. Entering this password will be needed each time a remote connection via SSH is used. If you do choose to enter a password be sure to remember it, because you will need to enter the password every time you use SSH to log into an ARC computer.
Outcome¶
Files of the SSH keys should exist on your computer. Check with:
ls ~/.ssh
id_* and id_*.pub, for
instance, id_rsa and id_rsa.pub.
3. Using SSH to connect to a remote computer¶
In the terminal, to log in to
- a remote computer called
myhostname.com - with user name
myusername
use the command:
ssh myusername@myhostname.com
For Example, if the computer is matrix.math.vt.edu and your user name is
isolde run:
ssh isolde@matrix.math.vt.edu
If this is the first time you use ssh to connect to this remote machine, you will see a message like:
The authenticity of host 'matrix.math.vt.edu' cannot be established.
DSA key fingerprint is ...
Are you sure you want to continue connecting (yes/no)?
yes <Enter> to continue.
Using VS Code via SSH¶
It needs a few steps. First, let's assume that you want to replicate the command
ssh myusername@myhostname.com
- add the "Remote - SSH extension" from the VS Code Marketplace
- open the "Command Palette" (
Ctrl+Shift+p) - type and select "Remote-SSH: Connect to Host..." and enter:
myusername@myhostname.com - if prompted, choose the server's platform (Linux most likely)
See the official documentation for details: