Scp does not need to enter a password for copying between Linux hosts

Source: Internet
Author: User
Tags scp file scp command
Article title: scp does not need to enter a password for copying between Linux hosts. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Copy the ssh public key file of your local host user to the remote host User's ~ In the/. ssh/authorized_keys file, assume that the local host linux (10.1.1.1) and remote host linux (10.1.1.2)

1. users in the linux100 host

Run

# Ssh-keygen-t rsa

The result is as follows:

Generating public/private rsa key pair.

Enter file in which to save the key (/home/. username/ssh/id_rsa): # Press Enter

Enter passphrase (empty for no passphrase): # Press Enter

Enter same passphrase again: # Press Enter

Your identification has been saved in/home/. username/. ssh/id_rsa.

Your public key has been saved in/home/. username/. ssh/id_rsa.pub.

The key fingerprint is:

38: 25: c1: 4d: 5d: d3: 89: bb: 46: 67: bf: 52: af: c3: 17: 0c username @ localhost

Generating RSA keys:

Key generation complete.

Will be in the user directory ~ /. Ssh/generate two files: id_rsa, id_rsa.pub

2. copy the id_rsa.pub file on the linux (10.1.1.1) host to the. ssh directory in the root user home directory of the linux (10.1.1.2) host and change it to authorized_keys.

That is:

/Root/. ssh/authorized_keys

In this way, the scp command is used on the linux100 host to copy the file to linux (10.1.1.2) without prompting to enter the password. And vice versa!

3. copy a file or directory command:

Copy a file:

(1) copy Local files to remote

Scp file name -- user@10.1.1.2: remote path

(2) remotely copy the file back to local

Scp -- user@10.1.1.2: Local path of file name

Copy Directory:

(1) copy the local directory to a remote

Scp-r directory name -- user@10.1.1.2: remote path

(2) remotely copy the directory back to local

Scp-r -- user@10.1.1.2: directory name local path.

Related Article

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.