首页 运维干货ssh-agent管理ssh密钥

ssh-agent管理ssh密钥

运维派隶属马哥教育旗下专业运维社区,是国内成立最早的IT运维技术社区,欢迎关注公众号:yunweipai
领取学习更多免费Linux云计算、Python、Docker、K8s教程关注公众号:马哥linux运维

ssh-agent是ssh其中一个组件,可以用来管理密钥和传送证书。

ssh-agent的man原文
DESCRIPTION
ssh-agent is a program to hold private keys used for public key authenti-
cation (RSA, DSA, ECDSA). The idea is that ssh-agent is started in the
beginning of an X-session or a login session, and all other windows or
programs are started as clients to the ssh-agent program. Through use of
environment variables the agent can be located and automatically used for
authentication when logging in to other machines using ssh(1).

ssh-agent代理允许使用ssh登陆已经配置ssh信任关系的机器,并在这些已经配置同样信任关系的机器间跳转,而不需要再次鉴权。

例如: 在不设置ssh-agent的情况下 机器bbb,ccc和ddd上都已经配置了aaa机的公钥
从aaa机器登陆bbb后,如果需要登陆ccc或者ddd机器 就必须是先退出bbb再重新登陆ccc或者ddd
root@aaa$ ssh bbb
root@bbb$ ssh ccc 如果从bbb上登陆ccc, 会因为没有信任关系提示要求输入密码
root@ccc’s password:

这就是ssh-agent要解决的问题,通过所有服务器上存放私钥副本,可以不需要暴露私钥。
你所需要做的是在aaa上启动ssh-agent代理,然后ssh-add添加默认的ssh密钥。
root@aaa$ ssh-agent
SSH_AUTH_SOCK=/XXXXXXX/XXX/agent.401; export SSH_AUTH_SOCK;
SSH_AGENT_PID=402; export SSH_AGENT_PID;
root@aaa$ ssh-add
不过你还需要在bbb,ccc和ddd机器上配置ssh客户端转发代理请求,配置/etc/ssh/ssh_config(不同操作系统位置不大一样)
ForwardAgent Yes

这样当aaa登陆bbb,然后跳转ccc的时候,bbb会要求ssh-agent提供有效证书,甚至再继续跳转倒ddd上,ccc会先和bbb协商转发请求给aaa的ssh-agent.

本文链接:https://www.yunweipai.com/713.html

网友评论comments

发表回复

您的电子邮箱地址不会被公开。

暂无评论

Copyright © 2012-2022 YUNWEIPAI.COM - 运维派 京ICP备16064699号-6
扫二维码
扫二维码
返回顶部