SSH verification solves the problem where a password is required for Remote File copying and file synchronization.

Source: Internet
Author: User

When we use SCP to copy files to a remote host, we need to enter a password between the remote hosts to copy the files. When you use rsync to synchronize files between two hosts, you also need to enter the password of the remote host to synchronize the files.

However, when we use scripts to copy files and synchronize documents between two hosts, we cannot manually enter the password between the other hosts.

After SSH authentication is performed between two hosts, the two hosts can directly log on to the other host using SSH without entering the password of the other host. When copying files and synchronizing documents, you do not need to enter a password.

This makes it easy to directly copy and synchronize data in the script automatically, instead of worrying about entering the password during Automatic copy.

Implement SSH verification between two hosts a (192.168.3.10) and B (192.168.3.11:

1) implement a direct SSH login to B

Run the ssh-keygen-t rsa command on host. RSA is optional for encryption methods, including RSA and DSA, and DSA is the default mode.

Run the RSA command and press the Enter key three times to generate the id_rsa and id_rsa.pub files under the/root/. Ssh Directory, which are the key files and Private Key Files respectively.

Run SCP/root/. Ssh/id_rsa.pub root@192.168.3.11:/root/. Ssh/authorized_keys to copy the id_rsa.pub file in a to the same directory in B and name it authorized_keys.

Copy the id_rsa.pub file to B and generate a host file in the/root/. Ssh directory of.

Now you can log on to host B directly using the SSH 192.168.3.11 command without entering the password. However, you cannot log on to host a directly using SSH on host B.

After performing the same operation on host B, you can directly log on to host a through SSH on host B.

2) Implement B's direct SSH login to

InBOn the host, run the ssh-keygen-t rsa command.

Copy the file id_rsa.pub to host a and name it authroized_keys.

If you swap the IP addresses between machine A and machine B, the SSH verification they have previously performed will become invalid, and you need to re-verify them.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.