ssh-agent是一个密钥管理器,运行ssh-agent以后,使用ssh-add将私钥交给ssh-agent保管,其他程序需要身份验证的时候可以将验证申请交给ssh-agent来完成整个认证过程。
$eval `ssh-agent -s` 注意这里是反引号
为了使ssh-agent自动运行,将它写到profile中,在/etc/profile.d下新建ssh-agent.sh文件:
$sudo gedit /etc/profile.d/ssh-agent.sh
将以下语句加入
#!/bin/sh
if [ -f ~/.agent.env ]; then
else
fi
这样就不会生成太多的ssh-agent程序,而且支持GUI环境。打开终端:
Stale agent file found. Spawning new agent…
Agent pid 2543
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
添加了新的密钥。