ssh无密码登入设置

发表于2009年11月25日|分类:ubuntu/debian|5条评论

现有2台机器

1、服务器192.168.1.112

2、个人机192.168.1.110

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

步骤

1、创建密钥

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

Generatingpublic/privatersakeypair.

Enterpassphrase(emptyfornopassphrase):(忽略)

Entersamepassphraseagain:(忽略)

Youridentificationhasbeensavedin/home/miao/.ssh/id_rsa.

Yourpublickeyhasbeensavedin/home/miao/.ssh/id_rsa.pub.

2、复制公密到服务器

miao@u32-192-168-1-110:~/.ssh$scpid_rsa.pubmiao@192.168.1.112:/home/miao/.ssh/192.168.1.110

miao@192.168.1.112'spassword:

id_rsa.pub100%4040.4KB/s00:00

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

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

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

miao@debian-192-168-1-112:~/.ssh$

4、启动ssh-agent

如果ssh192.168.112返回Agentadmittedfailuretosignusingthekey

ps-Af|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-addid_rsa

6、完成

ssh

相关推荐