这几天在自己的ubuntu机器上,研究sector/sphere,突然发现我原来在公司配置ssh无密码登录的办法无效,后来搜索后知道了原因,现将ubuntu上设置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.110 >> 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