简体   繁体   English

如何使用私钥克隆git repo

[英]How to clone git repo using private key

I have read a few questions and answers on here regarding using ssh to clone a git repo, but none have worked for my scenario. 我已经在这里阅读了一些有关使用ssh克隆git repo的问题和答案,但是没有一个对我的情况有用。

My setup includes a server with a private git repo that I can pull from locally by running git pull . 我的设置包括一个带有私有git repo的服务器,我可以通过运行git pull从本地git pull I have a git config file on my local machine that tells it where to pull from. 我在本地计算机上有一个git config文件,告诉它从哪里提取。 It's been set up like this for a long time. 这样的设置已经有很长时间了。

I now need to pull from that same repo from a different server. 现在,我需要从其他服务器的同一存储库中提取。 I have the same exact .git/config on the new server as I do my local. 我在新服务器上使用与本地服务器相同的.git/config

When I run git pull on the new server, I want it to grab files from the current prod git repo just like my local machine does, but it gives me the error: 当我在新服务器上运行git pull时,我希望它像本地计算机一样从当前产品git repo抓取文件,但是它给了我错误:

ssh: connect to host mysite.com port 22: Connection refused fatal: Could not read from remote repository.

I would greatly appreciate any help in fixing this. 我会非常感激解决此问题的任何帮助。

Thanks for your time. 谢谢你的时间。

the following error 以下错误

ssh: connect to host mysite.com port 22: Connection refused ssh:连接到主机mysite.com端口22:连接被拒绝

indicates that the ssh-server on the host mysite.com is not reachable on port 22. 表示主机mysite.com上的ssh服务器在端口22上不可访问。

here's a number of ideas why: 这里有一些想法,为什么:

  • there is no ssh-server running at all 根本没有运行ssh服务器
  • there is an ssh-server running but a firewall is blocking access 有一个ssh服务器正在运行,但是防火墙阻止了访问
  • there is an ssh-server running but it is listening on a non-standard port 有一个正在运行的ssh服务器,但它正在非标准端口上侦听
  • you have accidentally mistyped the server-name (or the server-name is resolved to the wrong IP) 您不小心输入了错误的服务器名称(或服务器名称解析为错误的IP)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM