Gitosis post-receive hook部署知识库获取公钥错误 [英] Gitosis post-receive hook to deploy repository getting public key errors

查看:196
本文介绍了Gitosis post-receive hook部署知识库获取公钥错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的服务器上安装了gitosis安装程序,并且正在尝试创建一个post-receive挂钩,以检查远程计算机上工作目录的更改。



最初我得到一个错误,说无法打开/home/user/source/testing-local/.git/FETCH_HEAD:权限被拒绝,所以我改变了工作目录的组权属。 git文件夹添加到git用户。



继此之后,我得到了错误主机密钥验证失败哪个用户正在运行钩子,当然是git(愚蠢的我!),所以我在gitosis中为git用户设置了一个gitosis的密钥,并在gitosis.conf中启用了该密钥。现在我得到了旧的 Permission denied(publickey)。



我的post-receive hook如下所示:

 #!/ bin / bash 
while read oldrev newrev refname
do
if [ $ refname==refs / heads / master];然后
WORKDIR = / home / user / source / testing-local
export GIT_DIR = $ WORKDIR / .git
pushd $ WORKDIR> / dev / null
id
git pull --quiet> / dev / null
fi
done

id 调用只是用来检查我正在运行的用户。



是否有更简单的方法做到这一点?!我是否在设置中遗漏了某些关键字?

解决方案

您需要确保 $ HOME $ / code>环境变量为执行该钩子的git用户。



$ HOME / .ssh 是在握手期间ssh将寻找私钥的地方。

另外,确保gitosis上的ssh目录拥有正确的权限

  server $ chmod go-w〜 / 
server $ chmod 700〜/ .ssh
server $ chmod 600〜/ .ssh / authorized_keys

最后,在GitHub上查看Permission denied(publickey)部分,这重复了我上面提到的有关 HOME
$ b


这通常是由于 ssh 找不到您的密钥。

确保您的密钥位于defa ult location,〜/ .ssh



I have gitosis setup on my server and I'm trying to create a post-receive hook that will checkout changes to a working directory on the remote machine.

Initially I got an error saying cannot open /home/user/source/testing-local/.git/FETCH_HEAD: Permission denied so I changed the group ownership of the working directory's .git folder to the git user.

Following this I got the error Host key verification failed which led me to check which user was running the hook, git of course (silly me!), so I setup a key in gitosis for the git user that gitosis is running under and enabled that in gitosis.conf. Now I'm getting the old Permission denied (publickey).

My post-receive hook looks like this:

#!/bin/bash
while read oldrev newrev refname
do
  if [ "$refname" == "refs/heads/master" ]; then
    WORKDIR=/home/user/source/testing-local
    export GIT_DIR=$WORKDIR/.git
    pushd $WORKDIR >/dev/null
    id
    git pull --quiet >/dev/null
  fi
done

The id call is just to check which user I'm running as.

Is there an easier way to achieve this?! Have I missed something key in my setup?

解决方案

You need to make sure of the value of the $HOME environment variable for the git user executing that hook.

$HOME/.ssh is where ssh will look for the private key during the handshake.
Also, make sure the ssh directory on the gitosis end
has the right permissions.

server$ chmod go-w ~/
server$ chmod 700 ~/.ssh
server$ chmod 600 ~/.ssh/authorized_keys

Finally see the "Permission denied (publickey)" section on GitHub, which repeat what I mentioned above about the HOME:

This is usually caused when ssh cannot find your keys.
Make sure your key is in the default location, ~/.ssh.

这篇关于Gitosis post-receive hook部署知识库获取公钥错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆