What is the password-free login method for ssh
The main content of this article is to explain "ssh password-free login method is what", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "ssh password-free login method is what" it!
For example, node1 password-free node2
The old method works on the company computer:
Ssh-keygen-t rsa
Step 2: add the public key to the public key file for authentication
Cat ~ / .ssh/id_rsa.pub > > ~ / .ssh/authorized_keys
The above has realized the password-free login to this machine.
Step 3: modify file permissions
Chmod 600 ~ / .ssh/authorized_keys
Step 4: copy the public key authorized_keys file back to each node
Scp / .ssh/authorized_keys root@node2:~/.ssh/
Scp / .ssh/authorized_keys root@node3:~/.ssh/
At this point, password-free login is completed. Test whether you can log in without a password
# ssh node2
If you do not prompt for a password and log in to node2 directly, the name configuration is successful.
But the company computer, no matter how I deal with it, no matter how to find a lot of methods on the Internet. Finally, a friend in the group instructed me to use the method:
Ssh-keygen generates public and private key pairs.
Ssh-copy-id copies the local public key to the authorized_keys file of the remote machine. Ssh-copy-id also gives you the right to home, ~. / ssh, and ~ /. Ssh/authorized_keys of the remote machine.
Step 1: use ssh-keygen on the local machine to generate public and private key pairs
Ssh-keygen-t rsa
Or go to the ~ / .ssh directory to execute ssh-keygen
Here's the point:
Step 2: copy the public key to the remote machine with ssh-copy-id
Ssh-copy-id-I / .ssh/id_rsa.pub node2
Ssh-copy-id-I ~ / .ssh/id_rsa.pub node1 (password-free for this machine, added by myself)
Note: ssh-copy-id writes key to the remote machine's ~ / .ssh / authorized_key. In the file
Step 3: log in to the remote machine without entering a password
Reference:
Ssh-keygen-t rsa-P ""-f ~ / .ssh/id_rsa
Ssh-copy-id-I ~ / .ssh/id_rsa.pub $dst
_ ip
Description:
Ssh-keygen creates public keys and keys.
Ssh-copy-id copies the public key of the local host to the authorized_keys file of the remote host.
Ssh-copy-id also sets appropriate permissions to the remote host's user home directory (home) and ~ / .ssh, and ~ / .ssh/authorized_keys
At this point, I believe that everyone on the "ssh password-free login method is what" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!