After you establish a secure trust relationship between the two users of the two machines, you do not need to enter the user's password when implementing the SCP command.
1. On the machine client, the root user executes the Ssh-keygen command to generate a certificate that establishes a secure trust relationship.
[Email protected] root]# ssh-keygen-b 1024-t rsagenerating public/private RSA key pair. Enter file in which to save the key (/ROOT/.SSH/ID_RSA): <– Direct Input Enter enter passphrase (empty for no passphrase): <– Direct output Into enter same passphrase again: <– Direct Input Enter your identification has been saved In/root/.ssh/id_rsa. Your public key have been saved In/root/.ssh/id_rsa.pub.the key fingerprint is: ...
Note: When the program prompts for passphrase, enter the carriage return directly, indicating that no certificate password is required.
The above command generates the private key certificate Id_rsa and the public key certificate id_rsa.pub, which is stored in the. SSH subdirectory of the user directory.
2. Copy the public key certificate id_rsa.pub to the. SSH subdirectory of the machine server's root directory, replacing the file name with Authorized_keys.
[Email protected] root]# scp-p ssh/id_rsa.pub [email protected]:/root/.ssh/authorized_keys[email protected] ' s Password: <– Enter the root user password for the machine server
When executing the above command, the root user of the two machines has not established a secure trust relationship, so the root user password of the machine server is also required.
After the above 2 steps, a secure trust relationship is established between the root of the machine client and the root of the machine server. Here we look at the effect:
[Email protected] root]# scp-p text [email protected]:/root
It worked! You really don't need to enter your password anymore.
Note: Do not use the. SSH subdirectory of the user directory in the private key certificate Id_rsa and the public key certificate Id_rsa.pub deleted, otherwise it would not be good to make
The SCP command does not require a user password to be entered under Linux