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
~). Give it permission using
mkdir -p ~/.ssh chmod 0700 ~/.ssh
Step 2: Generate RSA keys. Public + Private
ssh-keygen -t rsa
Simple. There will be
id_rsa.pub appearing in
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/id_rsa.pub username@server:~/.ssh/authorized_keys
or if there is one already, we append our public key to
cat ~/.ssh/id_rsa.pub | 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.
~/.ssh and see if there is a
config file. If not, make one. The syntax is as follows:
Host INPUT_YOUR_PREFERRED_ALIAS Hostname INPUT_HOSTNAME user INPUTYOURUSERNAME
add this information in. Then do
and bingo! :)