Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Ssh password-free login

Shulou Source: shulou.com Published: 2022-06-01 04:51:21 10月04日 Update

Ssh password-less login uses public and private keys. Under linux, you can use ssh-keygen to generate public / private key pairs. Let me take redhat 5 as an example.

There are machines A (192.168.122.223) and B (192.168.122.222). Now I want A to log in to B through ssh password-free.

1. Generate a public key / private key pair under machine A.

Add the-P parameter item to indicate the password, and-P''means the empty password, or you don't need the-P parameter, so you have to enter three cars and enter once with-P.

It generates a .ssh directory under / root, with id_rsa and id_rsa.pub under .ssh.

two。 Copy the id_rsa.pub under A machine to B machine, and in the .ssh/authorized_keys file of B machine, I copy it with scp.

Since there is no password-free login, you need to enter a password.

3.B machine adds the id_rsa.pub copied from machine A to the .ssh / authorized_keys file.

The permission of authorized_keys is 600.

4. Machine A logs in to machine B.

Now machine A can log in to machine B without a password.

Summary: the login machine can have a private key, and the logged-in machine must have the public key of the login machine. This public / private key pair is usually generated on the private key host. The above is the public / private key pair using the rsa algorithm, of course, you can also use dsa (the corresponding file is id_dsa,id_dsa.pub)

If you want An and B machines to log in to each other without a password, then B machines can be configured in the same way as above.

Tags: Login password public key file machine generation parameter have do not use host host summary method machine permission directory algorithm if input configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL NVidia Xiaomi Microsoft