Hadoop搭建笔记(23)

本文是我学习Hadoop搭建过程中的各种笔记,内容来自于各种公开的教程,起点非常低,从Linux基础开始,直至在PC上搭建Hadoop成功,是真正的从零开始。

 

感谢过程中帮助我的各位认识的和不认识的老师。

40、Ssh免登陆配置:

上面集群搭建好,也已经测试成功,但是在启停集群服务时需要输入密码,如果是几十台的就要一直输入密码,密码多次输入会导致服务不能正常启动或停止

借助ssh的免登陆:ssh:安全的一个shell,用它进行免登陆,在此启停服务,操作此台机子,跨机子操作另一台服务器都不用密码了

配置ssh:    ssh-keygen –t rsa

[root@hadoop01 hadoop-2.7.1]# 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: (按回车)

ac:b6:58:3c:95:ec:4c:42:3a:6d:16:90:dd:b2:11:0a root@hadoop01

The key's randomart image is: (按回车)

+--[ RSA 2048]----+

|  E .o.o         |

|   ..o+ .        |

|    . o+         |

|     +.+ .       |

|    o = S        |

|     = B         |

|      * o        |

|     + o         |

|    . .          |

+-----------------+

rsa指加密的类型。  按回车、回车、回车,生成一种图时可以了

此时多了两个目录id_rsaid_rsa.pub:  ll ~/ .ssh/

相当于生成公钥,私钥的对id_rsaid_rsa.pub  known-hosts:记载着访问过这台主机的一些主机名】

[root@hadoop01 hadoop-2.7.1]# ll ~/.ssh/

total 12

-rw-------. 1 root root 1675 Apr 26 10:24 id_rsa

-rw-r--r--. 1 root root  395 Apr 26 10:24 id_rsa.pub

-rw-r--r--. 1 root root 1218 Apr 26 08:41 known_hosts

在hadoop02上没有任何文件的: 

[root@hadoop02 local]# ll ~/.ssh/

total 0

设置免密码.ssh的三种方式:

选用第三种方式:

拷贝前,此时需要输密码 root:   ssh hadoop01

[root@hadoop01 hadoop-2.7.1]# ssh hadoop01

root@hadoop01's password:

Last login: Thu Apr 26 10:37:47 2018 from hadoop01

退出去:  exit

[root@hadoop01 ~]# exit

logout

Connection to hadoop01 closed.

把公钥拷贝到当前的机子上:ssh-copy-id hadoop01需要输密码

[root@hadoop01 hadoop-2.7.1]# ssh-copy-id hadoop01

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.

看有没有这个文件     ll ~/ .ssh/

[root@hadoop01 ~]# ll ~/.ssh/

total 16

-rw-------. 1 root root  395 Apr 26 10:41 authorized_keys

-rw-------. 1 root root 1675 Apr 26 10:24 id_rsa

-rw-r--r--. 1 root root  395 Apr 26 10:24 id_rsa.pub

-rw-r--r--. 1 root root 1218 Apr 26 08:41 known_hosts

刚才执行的命令,产生了authorized_keys这个文件,相当于把公钥复制的这个authorized_keys钥匙的文件里面

 

再次访问hadoop01,此时就不需要密码了  ssh hadoop01

[root@hadoop01 ~]# ssh hadoop01

Last login: Thu Apr 26 10:59:58 2018 from hadoop01

-bash: my: command not found  

在hadoop01远程登录hadoop02:  ssh hadoop02

此时不能过来,需要输入密码

[root@hadoop01 ~]# ssh hadoop02

root@hadoop02's password:

Last login: Thu Apr 26 09:13:22 2018 from 192.168.216.1

-bash: my: command not found

退出去:exit  

[root@hadoop02 ~]# exit

logout

Connection to hadoop02 closed.

在hadoop02上查看: ll ~/ .ssh/

[root@hadoop02 local]# ll ~/.ssh/

total 0

在hadoop01执行:ssh-copy-id hadoop02

[root@hadoop01 ~]# ssh-copy-id hadoop02

root@hadoop02's password:

Now try logging into the machine, with "ssh 'hadoop02'", and check in:

  .ssh/authorized_keys

to make sure we

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Demoatnes

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值