Using the scp command in Linux does not require a password to transfer files.

Source: Internet
Author: User

Using the scp command in Linux does not require a password to transfer files.

In a Linux environment, the scp command is generally used to transmit files between two hosts. Generally, when you use the scp command to obtain files from the other Linux host through ssh, you need to enter a password for confirmation.

However, by establishing a trust relationship, you do not need to enter a password.

Assume the IP address of A: 192.168.10.1.

IP address of B: 192.168.10.2

Copy the file from A without A password to B.


1. Run the following command on host A to generate A pair key:
Ssh-keygen-t rsa
Follow the prompts. Do not enter passphrase. The prompt is as follows:
Generating public/private rsa key pair.
Enter file in which to save the key (/root/. ssh/id_rsa ):
Enter passphrase (empty for no passphrase ):
Enter same passphrase again:
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:
Ff: 8e: 85: 68: 85: 94: 7c: 2c: 46: b1: e5: 2d: 41: 5c: e8: 9b root@localhost.domain

2. Copy the id_rsa.pub file in the. ssh directory to the ~ of host B ~ /. Ssh/directory, and renamed it authorized_keys.
Scp. ssh/id_rsa.pub 192.168.10.2:/root/. ssh/authorized_keys

In the future, no password will be required for scp from host A to host B.

3. When using this method, you must note that the two computers to be copied must use the same account name, and the root account is used here. For the sake of security, you need to create the same account on the two machines, and then switch to the account using the su command on the, and execute Step 2. This is possible when copying files in step 2. the ssh directory does not exist and needs to be created manually.

If the authorized_keys file already exists in the machine in step 1, you must note that this file can contain multiple SSH authentication information. In this case, you can use the cat> command to append the authentication file content.

For example, copy to scp. ssh/id_rsa.pub 192.168.10.2:/root/. ssh/a. pub

Then run cat ~ /. Ssh/a. pub> ~ /. Ssh/authorized_keys

Cp/scp command + scp command in Linux

CentOS cannot use scp command Solution

Copy files between two Linux Hosts using scp

Press scp transmission speed

Accelerate scp Transmission

Shell implements scp for batch file delivery

Ten SCP transmission command examples

This article permanently updates the link address:

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.