【问题标题】:Git post-receive hook: “remote: Permission denied, please try again.”Git post-receive hook:“远程:权限被拒绝,请重试。”
【发布时间】:2012-02-16 15:39:33
【问题描述】:

我在/home/dan/repo/ 有一个裸存储库,在/home/dan/www/project/ 有一个工作副本。
我想让工作副本在每次提交到repo 时自动将其当前分支从repo 拉出。

我在/home/dan/repo/hooks/post-update创建了一个文件:

#!/bin/sh

cd /home/dan/www/project || exit
unset GIT_DIR
git pull

exec git-update-server-info

工作副本的origin 设置为repo

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = dan@server:/home/dan/repo/

然而,每次提交时我都会收到一个错误:

remote: Permission denied, please try again.
remote: Permission denied, please try again.
remote: Permission denied (publickey,password).
remote: fatal: The remote end hung up unexpectedly

我该如何解决这个问题?

【问题讨论】:

    标签: git ssh githooks openssh


    【解决方案1】:

    从工作副本的.git/config 中的origin 远程url 中删除用户名解决了这个问题。

    之前:

    url = dan@server:/home/dan/repo/
    

    之后:

    url = /home/dan/repo/
    

    【讨论】:

    • 你使用的是ssh git仓库地址;我猜您没有将公钥/私钥对设置为通过sshlocalhost 自动登录到localhost。删除 dan@server: 意味着 git 将 repo 视为本地存储的存储库,而不是通过 ssh 访问。
    • 感谢您的解释。只是好奇,我该如何设置才能从localhost 登录到localhost?只是将id_rsa.pub添加到authorized_keys吗?
    • 是的 - cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys ; ssh user@localhost 应该可以工作。
    猜你喜欢
    • 2013-07-17
    • 1970-01-01
    • 2022-11-09
    • 2011-02-05
    • 1970-01-01
    • 2013-04-14
    • 2014-10-15
    • 2018-05-08
    • 2013-03-29
    相关资源
    最近更新 更多