Avoid entering the password (SCP without password) when using SCP for remote data transmission)

Source: Internet
Author: User

Assume that the local machine is client and the remote machine is server.
For example, copy/usr/A from the logged-on client (192.168.1.1) to the/usr directory of server (192.168.1.2,
The command is as follows:
SCP-r/usr/A root@192.168.1.2:/usr
Enter the server password and wait for a moment,
After entering the correct password,
Start copying all files under directory A to the server.
If you just copy an object,
The-R parameter is removed, for example:
SCP/usr/A/index.html root@192.168.1.2:/use//
You will find that using commands is a very convenient and quick way. However, if you do not want to enter a password, you need to establish a trust relationship between the two machines.

To establish a security trust relationship between the root of the client and the root of the server:
1. Run the ssh-keygen command on the client to generate a certificate that establishes a security trust relationship.
[Root @ client root] # ssh-keygen-B 1024-T RSA
Generating public/private RSA key pair.
Enter file in which to save the key (/root/. Ssh/id_rsa ):
Enter passphrase (empty for no passphrase): <-- press ENTER
Enter same passphrase again: <-- press ENTER
Your identification has been saved in/root/. Ssh/id_rsa.
Your public key has been saved in/root/. Ssh/id_rsa.pub.
The key fingerprint is:
49: 9C: 8A: 8f: BC: 19: 5E: 8c: C0: 10: D3: 15: 60: A3: 32: 1C root @ Client
[Root @ client root] #
Note: When the program prompts you to enter passphrase, enter the carriage return, indicating no certificate password.
The above command generates the Private Key Certificate id_rsa and Public Key Certificate id_rsa.pub, which are stored in the/root/. Ssh/subdirectory.
2. copy the Public Key Certificate id_rsa.pub to/root/of the server /. in the ssh/subdirectory, if the/root /. if no authorized_keys exists in SSH/, rename id_rsa.pub to authorized_keys /. if the authorized_keys file already exists in SSH/, add the id_rsa.pub content to the end of the authorized_keys file. [You can use the cat id_dsa.pub> authorized_keys command, or use Vim to open authorized_keys for compilation.]
3. Now we can use SCP for remote data transmission and avoid entering a password.

From: http://blog.csdn.net/dupei/article/details/6177538

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.