Hadoop集群搭建的密钥配置SSH实现机制的配置(2)

时间:2023-11-24 20:59:02
[hadoop@weekend110 ~]$ ssh-keygen -t rsa    用来生产密钥对
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): 不要输入密码
Enter same passphrase 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:
7b:4a:0d:::ec:b6:0c:::d9:c6:c1:f8:: hadoop@weekend110
The key's randomart image is:
+--[ RSA ]----+
|.X.o.o. |
|E B ... . |
| + . .. . . |
| o . o. . |
| . + .S |
| o + |
| o o |
| . o |
| . |
+-----------------+
[hadoop@weekend110 ~]$ ll -a 密钥文件为隐藏 需要加-a
total
drwx------. hadoop hadoop Oct : .
drwxr-xr-x. root root Mar ..
drwxrwxr-x. hadoop hadoop Oct : app
-rw-------. hadoop hadoop Oct : .bash_history
-rw-r--r--. hadoop hadoop Feb .bash_logout
-rw-r--r--. hadoop hadoop Feb .bash_profile
-rw-r--r--. hadoop hadoop Feb .bashrc
drwxr-xr-x. hadoop hadoop Oct : .cache
drwxr-xr-x. hadoop hadoop Oct : .config
drwx------. hadoop hadoop Oct : .dbus
-rw-------. hadoop hadoop Oct : .esd_auth
drwx------. hadoop hadoop Oct : .gconf
drwx------. hadoop hadoop Oct : .gconfd
drwxr-xr-x. hadoop hadoop Oct : .gnome2
drwx------. hadoop hadoop Oct : .gnome2_private
drwxrwxr-x. hadoop hadoop Oct : .gnote
drwx------. hadoop hadoop Oct : .gnupg
drwxrwxr-x. hadoop hadoop Oct : .gstreamer-0.10
-rw-rw-r--. hadoop hadoop Oct : .gtk-bookmarks
drwx------. hadoop hadoop Oct : .gvfs
-rw-rw-r--. hadoop hadoop Oct : hadoop-2.4..tar.gz
-rw-------. hadoop hadoop Oct : .ICEauthority
-rw-r--r--. hadoop hadoop Oct : jdk-7u65-linux-i586.tar.gz
drwxr-xr-x. hadoop hadoop Oct : .local
drwxr-xr-x. hadoop hadoop Oct : .mozilla
drwxr-xr-x. hadoop hadoop Oct : .nautilus
drwx------. hadoop hadoop Oct : .pulse
-rw-------. hadoop hadoop Oct : .pulse-cookie
drwx------. hadoop hadoop Oct : .ssh
drwxr-xr-x. hadoop hadoop Oct : Templates
-rw-------. hadoop hadoop Oct : .viminfo
-rw-------. hadoop hadoop Oct : .xsession-errors
-rw-------. hadoop hadoop Oct : .xsession-errors.old
[hadoop@weekend110 ~]$ cd .ssh 进入密钥文件
[hadoop@weekend110 .ssh]$ ll
total
-rw-------. hadoop hadoop Oct : id_rsa 私钥
-rw-r--r--. hadoop hadoop Oct : id_rsa.pub 公钥
-rw-r--r--. hadoop hadoop Oct : known_hosts
[hadoop@weekend110 .ssh]$ scp id_rsa.pub spark01:/home/hadoop 将密钥传到spark01机器,因为这里模拟,并没有次主机,错误正常
ssh: Could not resolve hostname spark01: Name or service not known
lost connection
[hadoop@weekend110 .ssh]$
此后在spark01配置 ,进入.SHH文件。第一次是没有authorized_key这个文件夹,用touch创建,创建之后将权限改为-rw-------即可。然后将公钥追加到此文件即可。
[hadoop@spark01 .ssh]$ cat ../id_rsa.pub >>./authorited_key 前面的../id_rsa.pub 代表的是前一个主机传过来的公钥,不是spark01中ssh文件里的id_rsa.pub 结束。