Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1493747
  • 博文数量: 230
  • 博客积分: 474
  • 博客等级: 下士
  • 技术积分: 1955
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-19 18:40
文章分类

全部博文(230)

文章存档

2020年(3)

2019年(3)

2018年(12)

2017年(13)

2016年(11)

2015年(55)

2014年(74)

2013年(39)

2012年(2)

2011年(18)

我的朋友

分类: LINUX

2013-03-14 16:43:28

ssh无密码登入设置(完全版)/linux下免输入密码ssh登录

配置ssh不需要密码登录远程主机,网上有很多文章,但好像完整的不多,笔者参照操作,但得到消息:

Agent admitted failure to sign using the key.

原来是没有启动ssh-agent及把私钥加入到ssh-agent,参考如下文章得以解决问题。下文是完整的配置无密码登录ssh远程主机的方法,推荐参阅。

[注]正文来自http://www.jiangmiao.org/blog/559.html,在此表示感谢!

 

现有2台机器

1、服务器192.168.1.112

2、个人机192.168.1.110

要使110无需密码通过ssh登入112

步骤

1、创建密钥

miao@u32-192-168-1-110:~/.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 /home/miao/.ssh/id_rsa.
Your public key has been saved in /home/miao/.ssh/id_rsa.pub.

2、复制公密到服务器

miao@u32-192-168-1-110:~/.ssh$ scp id_rsa.pub miao@192.168.1.112:/home/miao/.ssh/192.168.1.110
miao@192.168.1.112's password:
id_rsa.pub                                                                   100%  404     0.4KB/s   00:00
miao@u32-192-168-1-110:~/.ssh$

3、添加公密到192.168.112的信任区域

miao@debian-192-168-1-112:~/.ssh$ cat 192.168.1.110 >> authorized_keys
miao@debian-192-168-1-112:~/.ssh$

注: 2,3两步可由命令ssh-copy-id一步到位

miao@ubuntu-192-168-1-110:~/.ssh$ ssh-copy-id miao@192.168.1.112
Password:
Now try logging into the machine, with "ssh 'miao@192.168.1.112'", and check in:

  .ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.

4、启动ssh-agent

如果ssh 192.168.112返回 Agent admitted failure to sign using the key
ps -Af | grep agent查看有无ssh-agent有无运行,若没有

miao@u32-192-168-1-110:~/.ssh$ ssh-agent

5、添加id_rsa到ssh-agent

miao@u32-192-168-1-110:~/.ssh$ ssh-add id_rsa

6、完成

from http://www.jiangmiao.org/blog/559.html

阅读(1345) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

mingfei102013-04-25 14:06:57

若执行ssh-add /path/to/xxx.pem是出现这个错误:Could not open a connection to your authentication agent,则先执行如下命令即可:

  ssh-agent bash