In the linux environment, the scp command is generally used to transfer files between two hosts. Usually, the scp command is used to obtain the other party's linux host file through ssh to confirm the password.By building trust relationships,Can be achieved without entering a password,Interested friends follow us to learn the skills of copying files with scp under Linux without entering a password

When two Linux hosts want to transfer files to each other, you can use the scp command to achieve this.You do not need to enter a password after establishing a trust relationship.Copy the ssh public key file of your local host user to the ~/.ssh/authorized_keys file of the remote host user. Assuming local host linux100, remote host linux200

First, users in the linux100 host


#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):#Enter

enter passphrase (empty for no passphrase):

enter same passphrase again:#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:

generating rsa keys:

key generation complete.

Will generate two files in the user directory ~/.ssh /,id_rsa, id_rsa.pub

Second, copy the id_rsa.pub file on the linux100 host to the root user's home directory on the linux200 host.under the ssh directory, and renamed authorized_keys

which is:


In this way, using the scp command on the linux100 host to copy the file to linux200 will not prompt for a password.Copy it directly.You can also use the scp command on the linux100 host to copy the files on linux200 to this machine;In short no verification is needed,You can access linux200 on linux100

vice versa!

Note:If there are multiple computers that need to be copied with linux200,Just copy the contents of id_rsa.pub to the authorized_keys file.(Not verified on ssh,linux200 can only work with one server without authentication)

Third, the copy file or directory command:

Copy file:

(1) Copy local files to remote

scp file name [email protected] or computer name:remote path

(2) Copy files back to local from remote

scp [email protected] or computer name:file name local path

Copy directory:

(1) Copy the local directory to the remote

scp -r directory [email protected] or computer name:remote path

(2) Copy the directory from the remote back to the local

scp -r [email protected] or computer name:directory name local path

[@ more @]

  • Previous Five tips to speed up ASP
  • Next Detailed usage of distinct in oracle