1. 在主节点虚拟机内进行如下操作:
[root@hadoop1 tmp]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:
SHA256:Lr4xmEQSRRyRN2LSirJZYyi0/OdAUhWHzZF8o4ZmHYY root@hadoop1
The key's randomart image is:
+---[RSA 2048]----+
| .=**Boo |
| ..o*E+B o |
|oo++.o+.+ . |
|=+=+ + + |
|o=+.+ . S |
|o + + . |
| * + . |
| o + |
| o. |
+----[SHA256]-----+
[root@hadoop1 tmp]#
根据提示完成三次回车即可。
2. 切换到 root的家目录下,查看文件
[root@hadoop1 tmp]# cd /root/
[root@hadoop1 ~]# ll -a
总用量 52
dr-xr-x---. 16 root root 4096 3月 23 12:55 .
dr-xr-xr-x. 17 root root 224 3月 22 02:19 ..
-rw-------. 1 root root 1615 3月 22 02:20 anaconda-ks.cfg
-rw-r--r--. 1 root root 18 12月 29 2013 .bash_logout
-rw-r--r--. 1 root root 176 12月 29 2013 .bash_profile
-rw-r--r--. 1 root root 176 12月 29 2013 .bashrc
drwx------. 14 root root 4096 3月 23 12:56 .cache
drwxr-xr-x. 14 root root 261 3月 23 12:55 .config
-rw-r--r--. 1 root root 100 12月 29 2013 .cshrc
drwx------. 3 root root 25 3月 22 03:52 .dbus
-rw-------. 1 root root 16 3月 23 12:55 .esd_auth
-rw-------. 1 root root 314 3月 23 12:54 .ICEauthority
-rw-r--r--. 1 root root 1629 3月 23 13:02 initial-setup-ks.cfg
drwx------. 3 root root 19 3月 23 12:54 .local
drwx------. 5 root root 66 3月 23 12:55 .mozilla
drwx------. 2 root root 57 3月 23 13:11 .ssh
-rw-r--r--. 1 root root 129 12月 29 2013 .tcshrc
-rw-------. 1 root root 2758 3月 23 12:45 .viminfo
-rw-------. 1 root root 104 3月 23 2022 .xauth1MBjab
drwxr-xr-x. 2 root root 6 3月 23 12:55 公共
drwxr-xr-x. 2 root root 6 3月 23 12:55 模板
drwxr-xr-x. 2 root root 6 3月 23 12:55 视频
drwxr-xr-x. 2 root root 6 3月 23 12:55 图片
drwxr-xr-x. 2 root root 6 3月 23 12:55 文档
drwxr-xr-x. 2 root root 6 3月 23 12:55 下载
drwxr-xr-x. 2 root root 6 3月 23 12:55 音乐
drwxr-xr-x. 2 root root 6 3月 23 12:55 桌面
[root@hadoop1 ~]#
.ssh
目录内查看文件[root@hadoop1 ~]# cd .ssh/
[root@hadoop1 .ssh]# ll -a
总用量 16
drwx------. 2 root root 57 3月 23 13:11 .
dr-xr-x---. 16 root root 4096 3月 23 12:55 ..
-rw-------. 1 root root 1675 3月 23 13:11 id_rsa
-rw-r--r--. 1 root root 394 3月 23 13:11 id_rsa.pub
-rw-r--r--. 1 root root 541 3月 23 12:48 known_hosts
上述查询到的id_rsa
就是hadoop1的私钥、id_rsa.pub
则是hadoop的公钥