在我的服务器上,我有我的个人用户和另一个应用程序用户(app)。
我是(应用程序)用户我设置了我的 git 远程来源 - 我的 git conf 文件现在看起来像这样:
cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@github.example.com:example/mysite.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
问题是,为了 ssh 进入 git,它需要在我的用户(而不是应用程序用户)下使用我的个人 ssh key - 这通常是如何处理的?为我的(应用程序)用户创建一个新的 ssh key 似乎不太好 - 是否有一种配置方式可以理解为指向我的用户 .ssh/key?
最佳答案
But that ssh config will need to be under my app user and points to a key under my personal.ssh? I don’t think permissions will allow that
然后您需要创建一个专用 key ,以便应用程序用户使用正确的帐户访问远程存储库。
这仍然涉及 ~app/.ssh/config 文件,以便使用正确的(新)SSH key
Host ghperso
Hostname github.com
User git
IdentityFile ~/.ssh/dedicatedKey
然后 URL 将是:git remote set-url origin ghperso:example/mysite.git
关于Git Fetch - 使用特定用户的 ssh key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62746098/