简体   繁体   English

在具有共享用户的公共服务器上使用git私钥的最佳实践

[英]Best practice for using git private key on a public server with a shared user

I Currently use some servers to do some benchmarks. 我目前使用一些服务器来做一些基准测试。 I need to log into multiple servers and git clone ... from assembla. 我需要从assembla登录到多个服务器和git clone...。

Currently I copy my private key to the server and then update the .ssh/config file. 当前,我将私钥复制到服务器,然后更新.ssh/config文件。 Although I share this user and server with other people to do their benchmarks. 尽管我与其他人共享此用户和服务器来进行基准测试。 What is the best practice for this(without creating a new user for everyone on the server). 最佳做法是什么(不为服务器上的每个人创建新用户)。 Is there anyway I can use ssh-add key then use git on the server and pull the repo without storing the key on the server? 无论如何,我可以使用ssh-add密钥,然后在服务器上使用git并拉回购而不将密钥存储在服务器上吗?

Enable SSH agent forwarding 启用S​​SH代理转发

Since you're using key-based authentication, the best solution is to allow forwarding of the authentication agent connection over the secure channel . 由于您使用的是基于密钥的身份验证,因此最佳的解决方案是允许通过安全通道转发身份验证代理连接 If your public key is stored on the last server, there's no need to store your corresponding private key on the intermediate host. 如果您的公钥存储在最后一台服务器上,则无需在中间主机上存储相应的私钥。

Since the default client setting is not to forward the authentication agent to the remote host, you should enable agent forwarding in your client configuration. 由于默认的客户端设置不是将身份验证代理转发到远程主机,因此应在客户端配置中启用代理转发。 Add the following line to your ~/.ssh/config : ~/.ssh/config下行添加到~/.ssh/config

Host intermediate.server.name
    ForwardAgent yes

On the server, the default is to enable Agent Forwarding but in case it has been disabled, you should ensure that the following line is uncommented in the server's SSHD configuration (usually /etc/sshd_config ). 在服务器上,默认设置是启用代理转发,但如果已禁用它,则应确保在服务器的SSHD配置(通常为/etc/sshd_config )中取消注释以下行。

AllowAgentForwarding yes

GitHub have a good article on Using SSH agent forwarding which references Steve Friedl's comprehensive Guide to SSH Agent Forwarding . GitHub上有一篇有关使用SSH代理转发的好文章,其中引用了Steve Friedl的SSH代理转发综合指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM