
ssh-agent是一个密钥管理器,运行ssh-agent以后,使用ssh-add将私钥交给ssh-agent保管,其他程序需要身份验证的时候可以将验证申请交给ssh-agent来完成整个认证过程,下面为大家讲解一下配置ssh-agent免密码认证具体步骤。
生成密钥
$eval `ssh-agent -s` 注意这里是反引号
$ssh-add
为了使ssh-agent自动运行,将它写到profile中,在/etc/profile.d下新建ssh-agent.sh文件:
$sudo gedit /etc/profile.d/ssh-agent.sh
shell密钥脚本程序
#!/bin/shif [ -f ~/.agent.env ]; then
. ~/.agent.env >/dev/null
if ! kill -0 $SSH_AGENT_PID >/dev/null 2>&1; then
echo “Stale agent file found. Spawning new agent…”
eval `ssh-agent |tee ~/.agent.env`
ssh-add
fielse
echo “Starting ssh-agent…”
eval `ssh-agent |tee ~/.agent.env`
ssh-add
fi
这样就不会生成太多的ssh-agent程序,而且支持GUI环境。
打开终端
Stale agent file found. Spawning new agent…
Agent pid 2543
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
添加了新的密钥。
文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/224034.html<