ssh 不用密码

来源:互联网 发布:最准时时彩数据分析 编辑:程序博客网 时间:2024/05/18 00:07

同办公室的混蛋又犯病了。YB来找我,还我酒的钱。他在一旁,犬吠。说声音小点。可狗的叫声似乎更加吵人。没理它,习惯这种犯病过程了。


最近心态不错哈。


我的机器A是ubuntu. 

服务器B是centos. ip:2.3.4.5 user:m1

板子C是ubuntu.    ip:6.7.8.9 user:m2

我现在想用A ssh B,或是A ssh C。不用密码。scp也不用。

好像是密钥之类的东西。


在A上。

ssh-keygen

回车,回车,回车。

生成

id_rsa

id_rsa.pub


把id_rsa.pub copy到B的 ~/.ssh/authorized_keys,用

scp ~/.ssh/id_rsa.pub m1@2.3.4.5:/m1/.ssh/authorized_keys

这一次是要密码的。

然后,你ssh 或是scp有可能出问题。

比如:

Agent admitted failure to sign using the key


解決方式 使用 ssh-add 指令将私钥 加进来 (根据个人的密匙命名不同更改 id_rsa)
# ssh-add   ~/.ssh/id_rsa 

然后。就行了。


对于C,也是一样。

scp ~/.ssh/id_rsa.pub m2@6.7.8.9:/m2/.ssh/authorized_keys


这样,就可以用ssh ,scp  登录B或是C.不用密码了。

相当好。

0 0
原创粉丝点击