There are two machines a and B in the trust relationship between linux machines. Now we want to add user1 user of machine a to the user2 user trust list of machine B, so that user user1 of machine a can directly ssh to user 2 of machine B step: www.2cto.com 1, enter machine a/home/user1 /. run mkdir-p/home/user1 /. ssh: Check whether there is an id_rsa.pub file in the directory. If not, run the ssh-keygen-t rsa command to generate the file. copy the content of the file; 2, enter machine B/home/user2 /. create an ssh directory if no one exists. Execute vi authorized_keys in the directory, paste the copied content in step 1 in the last line, and save and exit;
3./etc/hosts of the vi B server. allow, add a line: sshd: [here is the ip address of machine a. If it is a dual path, add two ip addresses] Then run ssh user2 @ B in the user1 directory of machine, the device B is successfully connected. The trusted ssh trust relationship refers to a user on a server who trusts a client and allows the user to log on without entering a password. Another saying is public_key_auth. It is actually a Certificate Trust. First, you must create a certificate for a trusted user. Run the following command: ssh-keygen-t rsa will be in ~ /. Two files are generated under the ssh directory, id_rsa and id_rsa.pub, which are private keys and public keys respectively. Note that the permission of the id_rsa file must be 600. Then, go to the server user's ~ /. In the ssh directory, create an authorized_keys file (edit it if it already exists) and add the content (only one line of text) in id_rsa.pub to the file for saving. Now, run ssh username @ remotehost on the client to log on directly without entering the password. After setting the trust relationship, you can download a remote file from a shell script or execute commands on the server without entering the password: ssh username @ remotehost <EOF remote command... EOF sftp username @ remotehost <EOF get remotefile EOF