如何通过ssh连接到git服务器

时间:2020-10-12 05:25:47

标签: git ssh

我有位于域中的Linux机器服务器,并且已连接到LAN网络,我的计算机上有一个不在域中的centos7虚拟机,我想通过LAN网络连接到Linux机器服务器并用ssh命令推送我的git。但是我不能。有什么解决办法吗?

$ git clone ssh://git@10.100.184.17:22/hostextera.git 
Error :  does not appear to be a git repository 
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

2 个答案:

答案 0 :(得分:0)

第1步:使用您的git用户帐户,检查是否可以通过ssh连接到该Linux计算机:

ssh git@10.100.184.17

第2步:该Linux服务器上的hostextera存储库是一个常规目录,您应该提供一个正确指向该目录的路径

# either a relative one :
#   the part after the '/' will be relative to the home directory of the
#   `git` user home directory :
git clone ssh://git@10.100.184.17:22/repos/hostextera.git

# or an absolute one :
git clone ssh://git@10.100.184.17:22//usr/share/repos/hostextera.git


# as @pygeek pointed out, 22 is the default ssh port, you can use shorter urls :
git clone git@10.100.184.17:repos/hostextera.git
git clone git@10.100.184.17:/usr/share/repos/hostextera.git

答案 1 :(得分:0)

您需要在git控制台上查看正在使用的git用户的权限。如果您可以从本地PC访问Git服务器上的任何其他存储库。