在这种情况下,使用 openssh 而不是 putty 是关键。
原始答案(调试技巧)
我可以通过 ssh 登录git
user.
这意味着这有效:
ssh git@serverIp
你确实有一个HOME
定义的变量和 ssh 公钥/私钥(id_rsa
/ id_rsa.pub
) in %HOME%/.ssh/
.
这个问题 https://stackoverflow.com/a/13509396/6309建议使用不同的网址:
git remote set-url test git@serverIp:/home/git/test.git
确保您确实以 git 身份创建了 git 存储库(而不是以 root 身份创建,当您创建 git 帐户时,如这个问题 https://stackoverflow.com/q/15367016/6309).
ssh git@serverIp "which git"
应该返回 git 可执行文件的路径。
还要检查所有父目录是否有相关的x
为用户设置的(执行)位git
或团体gitgroup
, 跑步ls -ld /home /home/git /home/git/test.git
.
此外,可以通过以下方式获取 git 命令的更多信息:
-
git push --verbose
or:
GIT_TRACE=2 git push test master
如果您有带密码的 ssh 私钥,最好首先使用 ssh 私钥测试这些 ssh 命令not受密码保护,查看问题是否仍然存在。
或者,您可以保留受密码保护的 ssh 密钥,但是仔细检查你的.bashrc正如在这个答案中 https://stackoverflow.com/a/11918742/6309.
对于任何 ssh 连接问题(需要 git 的密码),请检查:
-
/var/log/auth.log
,
- an sshd 调试会话 https://serverfault.com/questions/130482/how-to-check-sshd-log
在你的情况下,因为它适用于ssh git@serverIp
(交互式安全外壳),但不能使用 git (它打开非交互式安全外壳),看看这个线程 https://groups.google.com/forum/?fromgroups=#!topic/git-users/fdxAkWOTTC8,其中引用this one http://lists.apple.com/archives/macos-x-server/2008/Jun/msg00251.html:
当使用命令行启动 ssh 时,会启动一个非交互式非登录 shell。
然而...bash
不使用$BASH_ENV
在这种情况下,所以将其设置为~/.ssh/environment
(例如,到/etc/profile
)没有帮助。
bash 所做的是源码/etc/bashrc
and ~/.bashrc
.
确保/etc/profile
确实定义了路径为git https://stackoverflow.com/a/15532349/6309,由于此处可以使用非登录帐户 https://stackoverflow.com/a/15651459/6309(这里似乎就是这种情况,因为ssh git@serverIp "which git"
工作过,并且ssh git@serverIp "git --version"
也应该)。
但也要检查正确的问题,并测试chmod 755
on /home
, /home/git
and /home/git/test.git
.