Git Fetch - 使用特定用户的 ssh key

标签 git github ssh

在我的服务器上,我有我的个人用户和另一个应用程序用户(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/

相关文章:

git - Composer git 存储库中的 "version"是否指的是 GitHub 上的发布(标签)?

linux - 为什么使用sftp上传文件后文件权限会发生变化?

node.js - 子模块不是 git 命令(在 Windows 的 GIT 上使用 NPM)

Git 庆典错误 : Could not fork child process: There are no available terminals (-1)

没有额外重量的 Git 子模块

Github Markdown - 使用 XML 和 HTML 渲染代码块 - kramdown vs redcarpet

Python ssh 读取镜像

git - Mac : SSH doesn't work anymore without changing something

git - 如何将我的分支重置为我在分离 HEAD 模式下创建的提交?

node.js - 为所有项目的 "Global"bower_components 文件夹创建工作流?