当前位置:网站首页>SSH无密码登陆
SSH无密码登陆
2022-06-29 03:19:00 【se7en_q】
一、环境
操作系统:CentOS
集群的ip:192.168.241.130 hadoopnamenode
192.168.241.131 hadoopdatanode1
192.168.241.132 hadoopdatanode2
用户:root,其他的也可以
ssh在~/.ssh或者/root/.ssh的目录下
二、如果你在启动hadoop集群的时候发现有报The authenticity of host 'localhost (127.0.0.1)' can't be established.的错误那说明你的ssh无密码登陆失败了,所以,不能让集群正常的进行。
1、配置hadoopnamenode(hadoopdatanode1|hadoopdatanode2以hadoopnamenode为例) 无密码登陆localhost
a、获取密钥对:
[email protected]:~# ssh-keygen -t rsa或者是ssh-keygen(如果你的ssh目录下有id_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:
c8:5e:3e:c1:9b:52:6f:24:a5:e4:c1:1c:00:8d:fb:3b [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
| .+... |
| . .o . |
| . = . |
| .. = + |
| .o S . |
| ..+ B |
| o.= o |
| E. o |
| . |
+-----------------+
b、把秘钥对保存到authorkeys_keys中
[email protected]:~/.ssh# cat id_rsa.pub >> authorized_keys
c、设置authorized_keys权限:
# chmod 600 authorized_keys
d、修改/etc/ssh/sshd_config文件中:
1.RSAAuthentication yes # 启用 RSA 认证
2.PubkeyAuthentication yes # 启用公钥私钥配对认证方式
3.AuthorizedKeysFile ~/.ssh/authorized_keys # 公钥文件路径
e、[email protected]:#ssh localhost验证是否可以无密码进入本地
2、配置hadoopnamenode 无密码登陆hadoopdatanode1和hadoopdatanode2(现以hadoopdatanode1为例)
a、将namenode上的公钥复制到datanode的机子上:
#scp ~/.ssh/authorized_keys [email protected]:~/.ssh/
这个命令还是要输入密码,这是正常的。
b、登陆hadoopdatanode1,将ssh目录的权限修改,即~/.ssh
chmod 700 ~/.ssh
c、把hadoopdatanode1的ssh目录下的id_rsa.pub的内容追加到authorized_keys中
#cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
d、把hadoopdatanode1中的id_rsa.pub删除掉
#rm ~/.ssh/id_rsa.pub
e、可以在hadoopnamenode上登陆hadoopdatanode1
[email protected]:#ssh hadoopdatanode1
3、保证hadoopdatanode1或者是hadoopdatanode2无密码登陆hadoopnamenode(以hadoopdatanode1为例)
a、hadoopdatanode1的公钥追加到hadoopnamenode上
#ssh-keygen -t dsa
#cat ~/.ssh/id_dsa.pub authorized_keys
b、hadoopdatanode1上的id_dsa.pub复制到hadoopnamenode 的ssh目录下,并把内容追加到authorized_keys中
#scp ~/.ssh/id_dsa.pub [email protected]:~/.ssh/
#cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keysc、验证hadoopdatanode1能否无密码登陆hadoopnamenode
[email protected]:#ssh hadoopnamenode
通过上面的操作是不是感觉特别的烦躁呢!其实总结就一句话,在authorized中要有hadoopnamenode的id_rsa.pub的秘钥还要有hadoopdatanode的id_dsa.pub的秘钥,也就是说将namenode的公钥和datanode的秘钥组合起来的authorized_keys就是让集群ssh无密码登陆,无论是master与slaver还是slaver与slaver之间,都是可以的。这是我研究出来的,希望对大家都有帮助。
边栏推荐
- For safe login of wechat applet, the openid returned by wechat must be verified first to ensure the uniqueness of information.
- Jerry's watch begins to move [chapter]
- 不同的二叉搜索树[自下而上回溯生成树+记忆搜索--空间换时间]
- 手机开户股票开户安全吗?开户很难么?
- Altium Designer中从已有的PCB中导出所有元件的封装的方法
- Yyds dry inventory everything a primary developer should know about activity
- In the name of love, fresh e-commerce companies rush to sell flowers on Valentine's Day
- 2022-2028 global CAE engineering service industry research and trend analysis report
- 设备监理师证书含金量怎样?值得考吗?
- LeetCode 每日一题——324. 摆动排序 II
猜你喜欢

Tu ne peux pas comprendre le feu?

【线程通信】

想当设备管理师?满足这三个报考条件就可以

解决allegro中测量距离时,点击一个点后光标闪烁的问题

Connect error: no route to host (errno:113)

Counter analysis of the parameter anti content in the backstage of the # yyds dry goods inventory # knife fight shop

认证培训|StreamNative Certification 培训第2期

Etcd教程 — 第六章 Etcd之核心API V3

2022-2028 global secondary butyl lithium industry research and trend analysis report
![[linear algebra] 1.2 total permutation and commutation](/img/04/18fc358c6c426e10c8598bcee9cd43.png)
[linear algebra] 1.2 total permutation and commutation
随机推荐
If you dare to write MQ message queue middleware on your resume, you must win these questions!
Tu ne peux pas comprendre le feu?
gcc编译器包
Démarrer le test - test d'intégration
不同的二叉搜索树[自下而上回溯生成树+记忆搜索--空间换时间]
Etcd tutorial - Chapter 7 etcd transaction API
Etcd tutorial - Chapter 6 etcd core API V3
Square root of X
【线程通信】
归并排序
Certification training | streamnational certification training phase 2
priority_ Understanding of queue
FortiGate firewall filters the specified session and cleans it up
Vscode plug-in used now
[test theory] quality analysis ability
问题——adb shellerror: insufficient permissions for device: verify udev rules.
測試入門——集成測試
Is the account opening of GF Securities really safe and reliable
层次分析法(AHP)
Tortoise 没有显示绿色图标