Git hook 和 ssh 代理转发
我有一个带有 git 存储库的远程开发服务器。
当我从本地计算机推送到此开发服务器时,它会运行 git hook after-receive 将开发分支推送到 Heroku 临时服务器上。
我的身份被转发到开发服务器,这是我的 ~/.ssh/config
Host *
User myuser
ConnectTimeout 15
ServerAliveInterval 45
ForwardAgent yes
IdentityFile ~/.ssh/id_rsa
我怎样才能让它被钩子使用来部署在heroku上?
目前它不使用转发的代理,而是使用开发服务器 ssh 身份。我们希望避免服务器上的 ssh 密钥,因为很多人都在推动。
非常感谢您的想法。
I've got a remote development server with a git repository.
When I push from my local machine to this dev server it runs the git hook after-receive to push the develop branch on a heroku staging server.
My identity is forwarded to the development server, here is my ~/.ssh/config
Host *
User myuser
ConnectTimeout 15
ServerAliveInterval 45
ForwardAgent yes
IdentityFile ~/.ssh/id_rsa
How can I make it used by the hook to deploy on heroku ?
For the moment it does not use the agent forwarded but uses the development server ssh identity. We want to avoid the ssh key on the server as many person are pushing.
Many thanks for your ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,我将其添加到 shell 会话的配置文件中(例如配置文件或 bashrc conf),它就完成了这项工作。
希望这会对某人有所帮助。
So I added this in the profile of my shell session (profile or bashrc conf for example) and it does the job.
Hopefully that will help someone.
由于您使用用户 myuser 连接到开发服务器,因此 git hook 也应该以 myuser 身份运行。
如果您尚未为用户 myuser 创建用于从您的开发服务器连接到 heroku 临时服务器的 ssh 密钥对,您需要执行以下操作那。
您需要在开发服务器上为用户 myuser 创建一个类似的 ~/.ssh/config,挂钩可以使用它来连接到登台服务器。
为了确认您可以从开发服务器尝试此命令,看看它是否可以登录登台服务器:
这应该是全部:)
Since you're connecting to the development server with your user myuser, the git hook should also be running as myuser.
If you've not already created ssh-keypairs for connecting to your heroku staging server from your development server for user myuser, you need to do that.
You need to create a similar ~/.ssh/config on your development server for the user myuser that can be used by the hook to connect to the staging server.
And to confirm you can try this command from your development server to see if it can login into the staging server:
That should be all :)