custom_hooks of gitlab in post-receive, ssh 到另一台服务器
custom_hooks of gitlab in post-receive, ssh to another server
我想在 post-receive
中添加 gitlab custom_hooks
。
我ssh
d到另一台服务器;我在另一台服务器上添加了id_rsa.pub
到authorized_keys
的内容,git
用户不用在终端输入密码就可以登录。
我推送的时候可以触发post-receive
,但是不能ssh
到服务器
有没有人知道这两种 ssh 之间的区别,或者有任何其他建议?
已解决。
gitlab 是通过 docker 安装的,因此执行 post-receive 的 git 用户是 gitlab docker 的用户。进入gitlab docker 并获取到另一台服务器的权限id_rsa.pub
后,问题解决。
感谢所有人,特别是@vonc。
post-receive can be trigger, but cannot ssh to the server
只需将您的 ssh 命令替换为 post-receive
脚本中的 ssh 调试命令即可:
- 首先添加
id -a
和 echo $HOME
以便 double-check 实际执行脚本的人 $HOME
(因为 ssh
会在 $HOME/.ssh
) 中寻找 id_rsa
- 然后添加
ssh -Tv xxx@server.yyy
以显示有关失败的 ssh 连接的调试信息。
这应该可以为您提供有关 "two types of ssh" 的线索。
OP 发现,这是因为错误的用户在玩:
The gitlab is installed via docker, so the git
user which executes post-receive
is user of gitlab docker.
After entering gitlab docker and get the right id_rsa.pub
to another server, the problem solved.
我想在 post-receive
中添加 gitlab custom_hooks
。
我ssh
d到另一台服务器;我在另一台服务器上添加了id_rsa.pub
到authorized_keys
的内容,git
用户不用在终端输入密码就可以登录。
我推送的时候可以触发post-receive
,但是不能ssh
到服务器
有没有人知道这两种 ssh 之间的区别,或者有任何其他建议?
已解决。
gitlab 是通过 docker 安装的,因此执行 post-receive 的 git 用户是 gitlab docker 的用户。进入gitlab docker 并获取到另一台服务器的权限id_rsa.pub
后,问题解决。
感谢所有人,特别是@vonc。
post-receive can be trigger, but cannot ssh to the server
只需将您的 ssh 命令替换为 post-receive
脚本中的 ssh 调试命令即可:
- 首先添加
id -a
和echo $HOME
以便 double-check 实际执行脚本的人$HOME
(因为ssh
会在$HOME/.ssh
) 中寻找 - 然后添加
ssh -Tv xxx@server.yyy
以显示有关失败的 ssh 连接的调试信息。
id_rsa
这应该可以为您提供有关 "two types of ssh" 的线索。
OP 发现,这是因为错误的用户在玩:
The gitlab is installed via docker, so the
git
user which executespost-receive
is user of gitlab docker.
After entering gitlab docker and get the rightid_rsa.pub
to another server, the problem solved.