SSH public key login setting method

■One-way login configuration:
1. Execute the following command
ssh-keygen -t dsa in the ~/.ssh/ directory of the local machine,
two files will be generated, id_dsa and id_dsa.pub

2. Copy id_dsa.pub to the remote machine , and add the content of id_dsa.pub to ~/.ssh/authorized_keys
cat id_dsa.pub >>authorized_keys

3. Modify file and directory permissions
chmod 600 ~/.ssh/authorized_keys
chmod 600 ~/.ssh

After completing the above operations, When the user executes ssh from the local machine to the remote machine, scp does not need to use a password

■Two-way login settings:
1. Perform operations on both machines:
  #ssh-keygen -t rsa
  and then press all Enter, using the default value.

2. This generates a pair of keys and stores them under ~/.ssh in the user directory.
Test the public key into the user directory of the other machine, and copy it to ~/.ssh/authorized_keys
#cat id_rsa.pub >> ~/.ssh/authorized_keys
After copying, delete the copied id_rsa.pub. (The id_rsa.pub generated on your own machine should be kept)

3. Set file and directory permissions:

set authorized_keys permissions
$ chmod 600 authorized_keys
Set the permissions of the .ssh directory (700)
$ chmod 700 -R .ssh

4. Make sure that both .ssh and authorized_keys have only the user's own write permission. Otherwise validation is invalid.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326657013&siteId=291194637