我正在尝试将部署密钥用于属于组织的存储库(我是管理员).
我创建了一个私钥/公钥对,公共被粘贴到"部署密钥"窗口,并被接受.然后我尝试git pull从远程存储库连接:
git add origin git@myserver.com:/organization/therepo.git
git pull
Run Code Online (Sandbox Code Playgroud)
我一直被要求输入用户的密码git.我试图用,而不是用户git,gogs,<my login>,<the name or the organization>-我被要求对每一次的密码.
我尝试了一个简单的方法ssh -v来检查向gogs提供了哪个密钥:它是正确的密钥(上面的私钥,对应于部署(公共)密钥).
我应该使用哪个用户进行连接?
故障排除想法的所有功劳都归功于David Cullen(通过他的评论)
问题是我调用了错误的sshd服务。
我的 GOGS 服务在 docker 中运行,ssh端口与主机服务器的端口不同(这是我使用默认端口 22 调用的端口):
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
86ddbabc8cbb gogs/gogs "docker/start.sh /bin" 13 days ago Up 3 minutes 0.0.0.0:3000->3000/tcp, 0.0.0.0:10022->22/tcp gogs
Run Code Online (Sandbox Code Playgroud)
通过使用类似的 ~/.ssh/config 文件
Host my.git.server.com
Port 10022
IdentityFile /var/www/.ssh/my.private.key.openssh
IdentitiesOnly yes
Run Code Online (Sandbox Code Playgroud)
我现在成功从远程服务器提取 GOGS 存储库:
$ git pull ssh://git@my.git.server.com:/organisation/therepo
From ssh://my.git.server.com:/organisation/therepo
* branch HEAD -> FETCH_HEAD
Already up-to-date.
Run Code Online (Sandbox Code Playgroud)
请注意,前面有一个斜杠organisation(回复:最初的评论)