SSH login without Password

glitchlist Uncategorized Leave a Comment

Sometimes to automate management operations, you need to manage the authentication process. To avoid inserting the login information of Linux systems into DevOps or NetOps scripts you can generate a pair of authentication keys.

  1. Generate a new pair of authentication keys:
techlab@Glitch01:~$ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/techlab/.ssh/id_rsa):
/home/techlab/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/techlab/.ssh/id_rsa.
Your public key has been saved in /home/techlab/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Q7KsCJ+cTCJhfiiu1yMKLbdz4a0q0D8Y17b09UslzM8 techlab@Glitch01
The key's randomart image is:
+---[RSA 2048]----+
| |
| |
|.. . . |
|o.. . + o |
|=+.. .o S + . |
|=O++o.+ .. = |
|+.XB.= o . .. E |
|+o=.B o . .. |
|o+o=.+ .. |
+----[SHA256]-----+

2. Copy the public key on the remote system:

cat .ssh/id_rsa.pub | ssh root@Glitch02 'cat >> .ssh/authorized_keys'

3. Test Login password-less:

ssh root@Glitch02

Bye

.glitchlist crew

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.