Generate a public key private key:
[Root @ client ~] # Ssh-keygen
Generating public/private RSA key pair.
Enter file in which to save the key (/root/. Ssh/id_rsa ):
Created directory '/root/. Ssh '.
Enter passphrase (empty for no passphrase ):
Enter same passphrase again:
Your identification has been saved in/root/. Ssh/id_rsa.
Your public key has been saved in/root/. Ssh/id_rsa.pub.
The key fingerprint is:
C6: 66: 93: 16: 73: 0b: BF: 46: 46: 28: 7d: A5: 38: A3: 4d: 6d root @ Client
The key's randomart image is:
+ -- [RSA 2048] ---- +
|. |
|. + O |
|. @ E |
| * &. |
|. S = |
| = +. |
| O |
|. |
|
+ ----------------- +
It is generated to ~ by default ~ /. Ssh:
[Root @ client ~] # Ls-L ~ /. SSH
Total 8
-RW -------. 1 Root 1675 Jul 27 :01 id_rsa
-RW-r --. 1 Root 406 Jul 27 :01 id_rsa.pub
Set permissions:
Chmod 700 ~ /. Ssh & chmod 600 ~ /. Ssh /*
Copy to server
[Root @ client ~] # SSH root @ server 'mkdir-P/root/. Ssh'
[Root @ client ~] # SCP/root/. Ssh/id_rsa.pub root @ server:/root/. Ssh/authorized_keys
[Root @ client ~] # SSH root @ server 'chmod 700/root/. Ssh & chmod 600/root/. Ssh /*'
Install necessary components
[Root @ client ~] # SSH root @ server 'yum install OpenSSH-clients'
The most important step is to modify the. Ssh permission if SELinux is enabled on the server. If SELinux is enabled on the server, you cannot log on even the above steps.
[Root @ client ~] # SSH root @ server 'restorecon-r-V/root/. Ssh'
Close the ticket ~