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.