Using SCP to copy files under Linux without having to enter a password _linux shell

Source: Internet
Author: User
Tags scp command

You can use the SCP command when you want to transfer files between two Linux hosts, without entering a password after establishing a trust relationship. Copy your local host user's SSH key file to the remote host user's ~/.ssh/authorized_keys file, assuming the local host linux100, remote host linux200

One, the user in the LINUX100 host

Run

#ssh-keygen-t RSA

The results are as follows

QUOTE:
Generating public/private RSA key pair.
Enter file in which to save the key (/HOME/.USERNAME/SSH/ID_RSA): #回车
Enter passphrase (empty for no passphrase): #回车
Enter same passphrase again: #回车
Your identification has been saved in/home/.username.
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 generate two files in the user directory ~/.ssh/, id_rsa,id_rsa.pub

Second, the id_rsa.pub file on the linux100 host is copied to the LINUX200 host root directory under the. SSH directory, and renamed to Authorized_keys

That

/root/.ssh/authorized_keys

This enables the use of the SCP command on the linux100 host to copy files to linux200 without prompting for a password, copy it directly. You can also use the SCP command on the LINUX100 host to copy the linux200 files to the native computer, and you can access the linux100 in the linux200 without authentication.

Vice versa!

Note: If you have multiple computers that need to be replicated with linux200, you can simply copy the contents of the id_rsa.pub to the Authorized_keys file. (Verified on SSH is not possible, linux200 can only be with one server does not need authentication)

Third, copy the file or directory command:

Copy files:

(1) Copy Local files to remote

SCP filename User name @ computer IP or computer name: remote path

(2) Copy files from remote to local

SCP User name @ computer IP or computer name: filename Local Path

Copy directory:

(1) Copy the local directory to the remote

Scp-r Directory Name-user name @ computer IP or computer name: remote path

(2) from the remote directory back to the local

SCP-R User name @ computer IP or computer name: directory name Local Path

[@more @]

The above is the introduction of this article in Linux with the SCP to copy files without the need to enter a password skills, I hope you like.

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.