Establish trust relationships between linux machines
Source: Internet
Author: User
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, to enable user user1 of machine a to ssh to user user2 of Machine B, follow these steps: www.2cto. com1, enter Machine a/home/user...
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
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.