多个开发人员如何“缓存”多个开发人员他们在远程计算机上的 Git 个人访问令牌?
在我们的团队中,我们需要直接在共享的远程计算机上开发代码。我们在这台机器上有一个 GitHub 存储库,我们中的一个人有时需要通过 SSH 连接到远程计算机,以开发代码,也许还需要从 GitHub 存储库拉取/推送到该存储库。我们每个人都可以从 GitHub 生成自己的个人访问令牌 (PAT),以在进行 Git 操作时使用。
在我们自己的 PC 上,这相当不错,因为我们使用 Git Credential Manager (GCM) 来缓存凭据(这非常安全,因为需要使用 Windows 登录信息等)来访问信息)。
但随后在(Linux)远程计算机上,我们在 /home/user/repository
处有一个存储库的克隆,其原始远程设置为类似 https://github.com/团队/blahblahblah
。然后,经过一番搜索后,我们找不到一种干净的方法来获取多个用户(多个用户名及其相应的 PAK)的 Git Credential Helper 存储凭据。我们最终每次都必须输入用户名和 PAK(是的,我们可以通过超时来缓存它,但这不是很有帮助)。
使用 GitHub SSH 远程,一种选择是每个人都可以在远程上拥有自己的安全、受密码保护的 SSH 密钥,因此每次人 A 想要执行 git 时,他们都必须提供密码来解锁 SSH 密钥。他们只需在 Git Config 上设置正确的作者姓名,以便读取正确的 SSH 密钥。
但我们正在寻找一种更清洁的方法来做到这一点。您知道这方面有什么特殊的工具或机制吗?
Within our team, we need to develop code directly on a shared remote machine. We have a GitHub repo on this machine, and from time to time one of us needs to SSH into the remote machine, to develop code, and perhaps pull from/push to the GitHub repo. Each of us can generate his/her own Personal Access Tokens (PAT) from GitHub, to use when doing Git operation.
On our own PCs this is pretty okay, as we use Git Credential Manager (GCM) to cache the credentials (and this is pretty much safe, since one needs to use, for instance, Windows Login information, to access the information).
But then on the (Linux) remote machine, we have a clone of the repo at /home/user/repository
with its origin remote set to something like https://github.com/team/blahblahblah
. Then after a bit of search we couldn't find a clean way to get the Git Credential Helper store credentials for multiple users (multiple usernames and their corresponding PAK). We end up having to enter username and PAK everytime (yes we can cache it with a timeout but that's not very helpful).
With GitHub SSH remote, one option was that everyone can have their own secure, password protected SSH key on the remote, so everytime person A wants to do git, they have to provide password to unlock the SSH key. They just need to set the correct author name on Git Config so that correct SSH key gets read.
But we are looking for a cleaner way to do this. Do you know any special tools or mechanism for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 SSH 而不是 HTTP,因此使用私钥而不是访问令牌,则可以通过SSH 代理转发轻松实现这一点。
简而言之:
-A
选项,或者在您使用的任何客户端中使用等效选项)。由于转发的代理仅在用户登录时可用,并且私钥本身不需要复制到服务器,因此这应该可以满足您的需求。
If you use SSH rather than HTTP, and therefore private keys rather than access tokens, you can achieve this easily with SSH Agent Forwarding.
In a nutshell:
-A
option to OpenSSH on the command-line, or an equivalent option in whatever client you use).Since the forwarded agent is only usable while the user is logged in, and the private key itself doesn't need to be copied to the server, this should meet your needs.