Copy your local host user's SSH public key file to the remote host user's ~/.ssh/authorized_keys file, assuming the local host Linux (10.1.1.1), remote host Linux (10.1.1.2)
One, the user in the LINUX100 host
Run
#ssh-keygen-t RSA
The results are as follows
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/.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 [email protected]
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 Linux (10.1.1.1) host to the. SSH directory under the root user directory of the Linux (10.1.1.2) host and rename it to Authorized_keys
That
/root/.ssh/authorized_keys
This allows the use of the SCP command on the linux100 host to copy files to Linux (10.1.1.2) will not prompt for a password, directly copied. Vice versa!
Third, copy the file or directory command:
To copy a file:
(1) Copy Local files to remote
SCP file name [email protected]: remote path
(2) Copy files back to local from remote
SCP [email protected]: File name Local path
To copy a directory:
(1) Copy the local directory to the remote
Scp-r directory name [email protected]: remote path
(2) Copy the directory back to local from remote
Scp-r [email protected]: Directory name local path.
SCP replicates between Linux hosts without entering a password