One,
Client server >>>
HOST1 configuration:
root edit / etc / ssh / sshd_config
RSAAuthentication yes // Enable RSA algorithm
PubkeyAuthentication yes // keys to enable verification
[root @ host1 ~] # useradd hadoop // build hadoop user
[root @ host1 ~] # passwd hadoop // set a password for the user
Hadoop change the user's password.
New Password:
Invalid Password: password less than eight characters
Re-enter the new password:
passwd: all authentication tokens have been successfully updated.
[host1 the root @ ~] # SU - hadoop // switch user to hadoop
Last Login: Five 8 Yue 16 03:44:00 CST 2019pts / 0
[hadoop@host1 ~]$ pwd
/home/hadoop
[Hadoop host1 @ ~] $ SSH-keygen -t rsa // generate a key pair, an encryption format rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa): // the key path
Created directory '/home/hadoop/.ssh'.
Enter passphrase (empty for no passphrase): // public key cryptography, that is, set an empty password Enter (carriage return)
Enter same passphrase again: // secondary input public key cryptography (carriage return)
Your identification has been saved in /home/hadoop/.ssh/id_rsa.
Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.
The key fingerprint is:
77:05:b5:65:b7:b6:81:79:79:6d:2d:13:e2:73:65:4e hadoop@host1
The key's randomart image is:
+ - [RS 2048] ---- +
| oo E |
| . ooX*|
| and *** |
| + O ++ |
| S . . . |
| . . |
| |
| |
| |
+-----------------+
[Hadoop host1 @ ~] $ SSH-Copy-ID -i .ssh / id_rsa.pub [email protected] // public key located in host2 and passed hatoop
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.
[hadoop @ host1 ~] $ SSH [email protected] // without authentication password to login
Last login: Thu Aug 15 20:10:32 2019 from 192.168.153.128
[hadoop@host2 ~]$
two,
Client server >>>
root edit / etc / ssh / sshd_config
RSAAuthentication yes // Enable RSA algorithm
PubkeyAuthentication yes // keys to enable verification
[hadoop@host2 ~]$ mkdir .ssh
[hadoop@host2 ~]$ chmod 700 .ssh/
[hadoop@host2 ~]$ ls -ld .ssh/
drwx------. 2 hadoop hadoop 6 8月 15 20:02 .ssh/
[hadoop@host2 ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa): // the key path
Enter passphrase (empty for no passphrase): // input of public key cryptography, enter a password that is empty (carriage return)
Enter same passphrase again: // input (Enter) again
Your identification has been saved in /home/hadoop/.ssh/id_rsa.
Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.
The key fingerprint is:
f3:37:cc:fa:98:d6:ed:79:db:b6:68:13:cf:21:5f:66 hadoop@host2
The key's randomart image is:
+ - [RS 2048] ---- +
| |
| |
| |
| |
| S |
| ooo .And |
| .. =. * And |
| .. = + O = + |
| . +. + And + = |
+-----------------+
[hadoop @ host2 ~] $ SSH-Copy-the above mentioned id -i .ssh / id_rsa.pub [email protected] // public key file pass HOST1
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.
[hadoop @ host2 ~] $ SSH [email protected] // log in directly, without having to verify the password
Last login: Fri Aug 16 04:12:03 2019 from 192.168.153.10
[hadoop@host1 ~]$