You don't need to enter a password to copy files with scp under Linux
This article mainly explains "how to use scp to copy files under Linux without entering a password", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to copy 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, and do not 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 that the local host linux100 and the remote host linux200
First, the users in the linux100 host
Running
# 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
Enter passphrase (empty for no passphrase): # enter
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:
38:25:c1:4d:5d:d3:89:bb:46:67:bf:52:af:c3:17:0c username@localhost
Generating RSA keys:
Key generation complete.
Two files will be generated in the user directory ~ / .ssh /, id_rsa,id_rsa.pub
Second, copy the id_rsa.pub file on the linux100 host to the .ssh directory under the root user home directory of the linux200 host, and rename it to authorized_keys
That is:
/ root/.ssh/authorized_keys
In this way, using the scp command on the linux100 host to copy the file to the linux200 will not prompt for a password, but will be copied directly. You can also use the scp command on the linux100 host to copy the files on linux200 to the local machine; in short, you can access linux200 on linux100 without verification
And vice versa!
Note: if you have multiple computers that need to copy with linux200, you only need to 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, copy the file or directory command:
Copy the file:
(1) copy local files to remote
Scp file name user name @ computer IP or computer name: remote path
(2) copy files back to the local area remotely
Scp user name @ computer IP or computer name: file name local path
Copy the directory:
(1) copy the local directory to the remote
Scp-r directory name-user name @ computer IP or computer name: remote path
(2) copy the directory back to the local area remotely
Scp-r user name @ computer IP or computer name: directory name local path
[@ more@]
At this point, I believe you have a deeper understanding of "how to copy files with scp under Linux without entering a password". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!