Git 服务器拒绝访问

Git Server Denying Access

我有一个 VPS 是用 GIT 设置的。我可以通过ssh使用git的用户名访问服务器。

$ssh gitvps   <-- Local 
git@linux-vps:~$ <-- Now remote

我在本地机器上的配置文件看起来像 -

Host gitvps
     HostName SERVERIP
     User git
     Port 22
     IdentityFile "~/.ssh/server/git/id_rsa"

我 运行 命令 ssh -vT gitvps 它说已验证但在它达到 debus1:Sending env LANG = en_US.UTF-8 之后挂起。

当我尝试使用 git 推送到我的遥控器时,它说我的密钥被拒绝。但是,所有迹象都表明我能够正常连接

git git@gitvps:/home/git/test.git

权限被拒绝。使用 GIT 时是否无法使用 SSH 配置文件来分解我所有的 id_rsa 密钥?

Is it not possible to use an SSH config file to break up all of my id_rsa keys when using GIT?

这是可能的,git 仓库的 url 将是 gitvps:/home/git/test.git(不需要前缀 git@

对于 .ssh/config 文件的 IdentityFile 部分,我更喜欢使用完整路径而不是依赖 ~.

确保您的远程服务器中的 .bashrc.profile.bash_profile 不会执行任何回显,并且不会触发任何不会 return 的进程立即。

同时检查您的路由器、防火墙或防病毒软件,如“git clone hangs forever on github”中所述。


作为 OP Aaron mentions in ,添加 ForwardAgent yes 有帮助。
参见“GitHub: Using SSH agent forwarding" and this article:

agent forwarding. In short, this allows a chain of ssh connections to forward key challenges back to the original agent, obviating the need for passwords or private keys on any intermediate machines

因此,如果在用户和 git 存储库托管服务器之间存在中间(代理?)服务器,这将很有用。
尽管在代理的情况下,文章“SSH Agent Forwarding considered harmful”建议改用 ProxyCommand 指令。

我在我的 ssh 配置文件中添加了 ForwardAgent yes,现在它可以工作了。我不明白为什么,但我很绝望,并尝试解决其他人遇到的问题。我现在可以克隆和推送了。

如果有人能解释为什么 ForwardAgent 对解决我的问题有用,那就太好了。