Skip to content

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:
    which ssh
    
    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. ✅
  • 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.

  1. Open a command line program/terminal locally on your computer.
  2. If you are using Windows, open the PowerShell.
  3. If you are running MacOS, open the Terminal.
  4. If you are using Linux, open the Terminal.

  5. Check if you have already generated SSH keys on your computer. If you have, you can skip this How-To.

  6. Change to your home directory. (Note: If you opened a fresh terminal, you are probably already there.)
    cd ~
    
  7. List file in directory .ssh

    ls .ssh
    
    If you see files of the pattern id_* and id_*.pub, for instance, id_ed25519 and id_ed25519.pub, then you can skip the next step.

  8. Generate a public-private pair of SSH keys for your computer.

  9. In most terminals, run
    ssh-keygen -t ed25519
    
  10. In Windows PowerShell, you may need to run
    ssh-keygen.exe -t ed25519
    
  11. Press Enter key to accept the suggested file location (usually <your_home_directory>/.ssh/id_rsa).
  12. 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
The output should include files of the pattern 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)?
This is to verify the server's identity and prevent impersonation. In this example, you can trust 'matrix.math.vt.edu': Type 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
in VS Code, do:

  • 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: