SSH Key Setup Guide
If you're using Windows, you need to use PowerShell for these commands to work. Linux and Mac's default terminals should work.
Check if you have an SSH key already:
ls ~/.ssh
If you have files that look something like id_XXXXX.pub, skip to displaying the public key.
Otherwise, generate a new key:
ssh-keygen
You can change the encryption standard and stuff with some flags, but I won't get into that here.
Display the public key:
cat ~/.ssh/id_ed25519.pub
Or if an RSA key was generated, do cat ~/.ssh/id_rsa.pub.
You should see the key in the terminal now. It should look something like ssh-ed25519 RandomCharacters name@server
Copy the ENTIRE LINE to your clipboard, including the "ssh-XXXXX" in the beginning and the "name@server" at the end.
Now SSH into your server:
ssh name@server
Run these commands on the server:
mkdir -p ~/.ssh
vim ~/.ssh/authorized_keys
Paste the key you copied earlier onto the next available line in the file. Since it's Vim, you would probably press
Shift+G to go to the end of the page, then i to enter insert mode, then Ctrl+Shift+V to paste the text.
Then press Esc and type :wq to save and quit.
This last step is usually optional, but you can also set the permissions for the SSH folder:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
If you need to add an ssh key to Github, do ssh-keygen on the server you want to push/pull to, and copy the public key to the ssh key section of your GitHub settings.
Just for fun, this is what the permissions mean:
7 111 read, write, execute (owner)
0 000 no access (group)
0 000 no access (others)
6 110 read, write (owner)
0 000 no access (group)
0 000 no access (others)