SSH No Password

SSH access with no password is sometimes required when you have backend processes like clustering or file sync between Servers that require username authorization with no password. In this post we’ll utilize ssh-keygen to create a no password rsa key pair and copy the authorized key from one host to another. After you’ve copied the auth key try logging into the destination host from the originating host and verify if you’re able to login without the requirement of having to enter a password.

In the following example we’re going to authorize unrestricted root access “no password” between CentOS Linux Servers.

Step 1:

Login to each server that you want to grant access between and run:
ssh-keygen -t rsa (press enter on all questions)

[root@vsd-01 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): [Press enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Press enter key]
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
40:ea:72:4b:93:c4:d7:0a:fe:b4:f3:ed:dc:c9:fe:59 root@lab.local
The key's randomart image is:
+--[ RSA 2048]----+
|      .          |
|   . o .         |
|    = o .        |
|   + + o         |
|  . B o S        |
|   + = .         |
|    . +         E|
|       o o o . o |
|        ..+.=.o  |
[root@vsd-01 ~]#

Step 2:

On each Server add the local servers public key to the authorized key file on the remote server.
Note: Must add individually as you need to enter a one time password each time.

cat .ssh/ | ssh root@ 'cat >> .ssh/authorized_keys'
cat .ssh/ | ssh root@lab.local 'cat >> .ssh/authorized_keys'

cat .ssh/ | ssh root@ 'cat >> .ssh/authorized_keys'
cat .ssh/ | ssh root@lab.local 'cat >> .ssh/authorized_keys'

cat .ssh/ | ssh root@ 'cat >> .ssh/authorized_keys'
cat .ssh/ | ssh root@lab.local 'cat >> .ssh/authorized_keys'

Categories: network services

Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: