[版本]ubuntu hadoop 环境创建 ssh 无密码登录 localhost

来源:互联网 发布:淘宝星期四数码店 编辑:程序博客网 时间:2024/05/05 13:26

链接:http://blog.sina.com.cn/s/blog_8714d04f0100t92k.html

最近有时间在研究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.pub sudo chmod 644 ~/.ssh/known_hosts  sudo chmod 755 ~/.ssh 6.登陆测试 ~/.ssh$ ssh localhost

0 0