Created by Run Chen (runchen@cs.columbia.edu)
Modified on March 28, 2024
Check if any public key already existed on your local machine
$ cd ~/.ssh
$ ls
You're looking for a pair of files named something like id_dsa or id_rsa and a matching file with a .pub extension.
The .pub file is your public key, and the other file is the corresponding private key.
If you don't have these files (or you don't even have a .ssh directory), you can create them by running a program called ssh-keygen
,
which is provided with the SSH package on Linux/macOS systems and comes with Git for Windows:
$ ssh-keygen -t ed25519
You will then be prompted to enter a secure passphrase, but you can leave that blank. You should now have a id_ed25519.pub file which contains your new public SSH key.
$ cat ~/.ssh/id_ed25519.pub
ssh-ed25519 [KEY] [USERNAME]@[LOCAL_MACHINE].local
Copy the entire line to your clipboard.
Log onto the remote lab machine assigned to you.
$ ssh [USER]@[LAB_MACHINE].cs.columbia.edu
If your account on the remote system doesn't already contain a ~/.ssh/authorized_keys
file, create one; on the command line, enter the following commands:
$ mkdir -p ~/.ssh
$ touch ~/.ssh/authorized_keys
Then add what you copied from id_ed25519.pub
on your local machine to the authorized_keys
file.
Install the extension
The Remote - SSH extension
is used to connect to SSH hosts.
[2] https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key