Ubuntu Hadoop 环境创建SSH无密码登录 localhost

最近有时间在研究Hadoop,想把环境搭建起来,开始就遇到一个头疼的问题,在Ubuntu 环境下用ssh服务连接loaclhost,搭建了好长时间才弄好,现在整理出来供搭建参考,现在网上有很多方法实现了master到slave实现的ssh无密码登陆,这里面就不做介绍了。废话不多说,步骤有下面几步:

步骤
1.创建密钥

~/.ssh$ ssh-keygen -t rsa  Generating public/private rsa key pair.  Enter passphrase (empty for no passphrase): (忽略)  Enter same passphrase again: (忽略)  Your identification has been saved in /.ssh/id_rsa.  Your public key has been saved in /.ssh/id_rsa.pub. 

2.添加公密到信任列表
~/.ssh$ cat 192.168.1.101 >> authorized_keys
~/.ssh$

3.启动ssh-agent (以前没有做过的步骤)
如果ssh localhost返回这样的提示
Agent admitted failure to sign using the key
ps -aux|grep agent查看有无ssh-agent有无运行,若没有
~/.ssh$ ssh-agent

4.添加id_rsa到ssh-agent
~/.ssh$ ssh-add id_rsa如果提示: “Could not open a connection to your authentication agent”  执行:ssh-agent bash  5.修改目录权限
sudo chmod 600 ~/.ssh/id_rsa sudo chmod 600 ~/.ssh/id_rsa.pubsudo chmod 644 ~/.ssh/known_hosts sudo chmod 755 ~/.ssh  6.登陆测试~/.ssh$ ssh localhost

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/795e7f5f46529e49e1f8d2cdd59c5fec.html