我有一个使用 GIT 设置的 VPS。我可以通过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 推送到远程时,它说我的 key 被拒绝。然而,所有迹象都表明我能够正常连接
git git@gitvps:/home/git/test.git
权限被拒绝。使用 GIT 时是否无法使用 SSH 配置文件来分解我的所有 id_rsa key ?
最佳答案
Is it not possible to use an SSH config file to break up all of my id_rsa keys when using GIT?
这是可能的,git repo 的 url 将是 gitvps:/home/git/test.git
(不需要前缀 git@
)
对于 .ssh/config
文件的 IdentityFile 部分,我更喜欢使用完整路径,而不是依赖 ~
。
确保远程服务器中的 .bashrc
、.profile
或 .bash_profile
不会执行任何回显,也不会触发任何不会立即返回的进程。
还请检查您的路由器、防火墙或防病毒软件,如“git clone hangs forever on github”中所述。
作为OP Aaron another answer 中提到,添加 ForwardAgent yes
会有所帮助。
请参阅“GitHub: Using SSH agent forwarding”和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
指令。
关于Git 服务器拒绝访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32683192/