如何在 SSH 会话中转发本地密钥对? [英] How to forward local keypair in a SSH session?
问题描述
我通过SSH手动部署网站,我在github/bitbucket中管理源代码.对于每个新站点,我目前正在服务器上生成一个新的密钥对并将其添加到 github/bitbucket,以便我可以从服务器中获取机会.
I manually deploy websites through SSH, I manage source code in github/bitbucket. For every new site I'm currently generating a new keypair on the server and adding it to github/bitbucket, so that I can pull chances from server.
我在 capistrano 中遇到了一个功能,它使用本地机器的密钥对将更新拉到服务器,即 ssh_options[:forward_agent] = true
I came across a feature in capistrano to use local machine's key pair for pulling updates to server, which is ssh_options[:forward_agent] = true
我怎样才能做这样的事情并将我本地机器的密钥对转发到我要通过 SSH 连接的服务器,这样我就可以避免为每个新站点将密钥添加到 github/bitbucket 中.
How can I do something like this and forward my local machine's keypair to the server I'm SSH-ing into, so that I can avoid adding keys into github/bitbucket for every new site.
推荐答案
原来这很简单,完整指南在这里 使用 SSH 转发
This turned out to be very simple, complete guide is here Using SSH Forwarding
本质上,你需要创建一个~/.ssh/config
文件,如果它不存在.
In essence, you need to create a ~/.ssh/config
file, if it doesn't exist.
然后,添加主机(文件中的域名或IP地址并设置ForwardAgent yes
)
Then, add the hosts (either domain name or IP address in the file and set ForwardAgent yes
)
示例代码:
Host example.com
ForwardAgent yes
让 SSH 生活更轻松.
Makes SSH life a lot easier.
这篇关于如何在 SSH 会话中转发本地密钥对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!