Skip to content

Logging in through SSH without a password

I normally don’t do this for my own personal account, but sometimes you need to use SSH in your scripts. Anyways, here we go:

I will refer to the server that you will access from as ‘Server_Alpha’, this is where the scripts would reside. The server that will be accessed, will be referred to as ‘Server_Beta’. The user wil be named, uhh, ‘User’.
First of all, make sure the user is in both machines. Once that is done, create a folder in your home directory with:

$ mkdir -p /usr/home/User/.ssh

Now to create the key:

$ ssh-keygen -t rsa

You will get a prompt and the output so far should be something like:

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/User/.ssh/id_rsa):

Hit Enter, and it will then prompt for a passphrase. Do not use a passphrase. Just hit the enter button twice.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

If successful, you will see something like this:

Your identification has been saved in /home/User/.ssh/id_rsa.
Your public key has been saved in /home/User/.ssh/id_rsa.pub.
The key fingerprint is:
2f:c3:ab:02:ea:f3:c6:3e:6a:21:f4:a8:45:e1:65:77 User@Server_Alpha

OK, we are done with Server_Alpha. Let’s move on to Server_Beta.

Make sure that a .ssh directory exists in the home directory and copy id_rsa.pub from Server_Alpha to A file named authorized_keys in the .ssh folder.

You can copy and paste, or use ssh. Just make sure that it is only one line!!

Done!!

Post a Comment

You must be logged in to post a comment.