Anni's Blogs

How to do passwordless ssh

Most GPUs and hard-core compute live on servers that you have to ssh into. Generally you're provided with an IP Address, a username and a password. Then, you run the following commands:

ssh username@ip-address
[prompted to enter password]

Entering the password each time you ssh into the machine can be tedious because it's highly likely that you're accessing this machine multiple times throughout each day. So, if you want to do passwordless ssh into remote machines, do the following:

Step 1: Generate a rsa key

I am not 100% sure how to do it, but this GitHub article says you can do it using the following command:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

So for me, this would have been:

ssh-keygen -t rsa -b 4096 -C "mukh.aniruddha@gmail.com"

Once you’ve done this, you should see a rsa and rsa.pub in your ~/.ssh folder.


Step 2: cat and copy the rsa.pub file

cd ~/.ssh/
cat rsa.pub
<then select the text & copy it using **( + C)**>

Step 3: Paste the rsa.pub in your remote machine:

Then in your remote server (the machine you’re going to ssh into), create a directory called ~/.ssh. Inside that directory create a file called authorized_keys that’s it, no extension etc.

Paste your public key there.

That’s it, bob’s your uncle. You should be able to do passwordless ssh from your laptop from there on out!