Hadoop集群配置免密码登录方法

准备3台虚拟机

  • hadoop01 192.168.88.131

  • hadoop02 192.168.88.132

  • hadoop03 192.168.88.133

ssh基本用法

ssh加另一台主机IP

免密登录原理

实现方法

配置主机与IP地址的映射

[root@hadoop01 .ssh]# vim /etc/hosts

添加下列代码

 192.168.88.131        hadoop01
 192.168.88.132        hadoop02
 192.168.88.133        hadoop03

每个节点生成ssh密钥

 [root@hadoop01 ~]# 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:
 86:28:2e:e1:91:91:97:57:12:9c:47:4c:e9:bb:32:cf root@hadoop01
 The key's randomart image is:
 +--[ RSA 2048]----+
 |    .o*+.        |
 |  . .oo+         |
 | o o .o          |
 |  + .. o         |
 |.o. . . S        |
 |.o..   o         |
 |...     .        |
 | .   o..         |
 |      +E         |
 +-----------------+
 [root@hadoop01 ~]# cd .ssh
 [root@hadoop01 .ssh]# ll
 总用量 12
 -rw-------. 1 root root 1675 6月  13 01:14 id_rsa
 -rw-r--r--. 1 root root  395 6月  13 01:14 id_rsa.pub

  • -rw-------. 1 root root 1675 6月 13 01:14 id_rsa //私钥文件

  • -rw-r--r--. 1 root root 395 6月 13 01:14 id_rsa.pub //公钥文件

  • -rw-r--r--. 1 root root 396 6月 13 01:05 known_hosts //记录连接过的计算机公钥信息**

复制SSH密钥到目标主机,开启无密码SSH登录

 [root@hadoop01 ~]# ssh-copy-id hadoop01
 The authenticity of host 'hadoop01 (192.168.88.131)' can't be established.
 RSA key fingerprint is db:b1:63:46:ea:f0:d4:57:d7:55:45:ce:d1:61:bd:d4.
 Are you sure you want to continue connecting (yes/no)? yes
 Warning: Permanently added 'hadoop01,192.168.88.131' (RSA) to the list of known hosts.
 root@hadoop01's password: 
 Now try logging into the machine, with "ssh 'hadoop01'", and check in:
 ​
   .ssh/authorized_keys
 ​
 to make sure we haven't added extra keys that you weren't expecting.
 ​
 [root@hadoop01 ~]# ssh-copy-id hadoop02
 ......
 [root@hadoop01 ~]# ssh-copy-id hadoop03
 ......

这样在hadoop01主机就可以免密登录hadoop02、hadoop03主机了,但在hadoop02和hadoop03上还不能免密登录。因此还要在hadoop02和hadoop03上执行该操作。

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值