Applied SSHs: Part 1

SSH keys are extremely useful when you are establishing access to a remote server, which could well be a GPU cluster or cloud server running on AWS or Azure. Here are some easy to understand steps that can help you conveniently access your servers.

Step 1: Generate RSA folder

If not already done, create a .ssh file in $HOME (equivalently ~). Give it permission using chmod.

mkdir -p ~/.ssh
chmod 0700 ~/.ssh

Step 2: Generate RSA keys. Public + Private

ssh-keygen -t rsa

Simple. There will be id_rsa and appearing in ~/.ssh now.

Step 3: Remote access

Your remote server almost certainly already has ~/.ssh all set up. If not, repeat steps 1 and 2 on the remote server.

If you don’t see authorized_keys in the remote server, you can either make one and simply replace it with your local public key

scp ~/.ssh/ username@server:~/.ssh/authorized_keys

or if there is one already, we append our public key to authorized_keys.

cat ~/.ssh/ | ssh username@server "cat >> .ssh/authorized_keys"

Step 4 (optional): Password-free ssh

Ok so you’re tired of typing in your password all the time and you just want a 1-liner.

Go to ~/.ssh and see if there is a config file. If not, make one. The syntax is as follows:



add this information in. Then do


and bingo! :)