我想在我的VPS服务器上运行git命令,如下所示:
ssh -A user@mydomain.com 'git ls-remote git@bitbucket.org:myuser/repo.git'
但我收到错误信息:
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我可以使用SSH代理转发运行其他命令.(在其他服务器上,此命令可以正常工作.)
"主机密钥验证失败"消息可能意味着VPS上的SSH客户端不信任git服务器.
试试这个:
ssh -A user@mydomain.com 'ssh -T -o StrictHostKeyChecking=no git@bitbucket.org < /dev/null'
ssh -A user@mydomain.com 'git ls-remote git@bitbucket.org:myuser/repo.git'
第一个命令应该使SSH密钥.ssh/known_hosts在VPS上缓存.从那时起,第二个命令应该工作.
你也可以通过.ssh/config在VPS用户帐户上创建一个包含这样的东西(未经测试)来解决这个问题:
Host bitbucket.org
    User git
    StrictHostKeyChecking no
假设上面的configuraiton片段有效,它将为您节省一个SSH连接.