简体   繁体   English

如何使用密钥通过ssh将私有服务器上的git repo克隆到本地计算机?

[英]How to clone git repo on private server to local machine via ssh with key?

Can't see any posts that address this specific question so here goes... 看不到任何针对这个特定问题的帖子,所以这里...

I have a git repo on a vps. 我在vps上有一个git repo。 the repo tracks a website (contained in public_html ) and also directories needed by that website (ie private , tmp , etc.). 存储库跟踪一个网站(包含在public_html )以及该网站所需的目录(即privatetmp等)。 Like this: 像这样:

    drwxr-xr-x  8 someuser someuser 4096 Jan 17 07:00 .git/
    drwxrwx---  5 someuser www-data 4096 Jan 17 07:00 private/
    drwxr-x--- 10 someuser www-data 4096 Jan 17 07:00 public_html/
    drwxrwx---  2 someuser www-data 4096 Jan 17 07:00 tmp/

as such, this repo is above the web root, not publicly accessible. 因此,此存储库位于网络根目录之上,不可公开访问。 ssh with key only access is set up on this linux system. 在此linux系统上设置了仅具有密钥访问权限的ssh。

I want to clone this remote git repo via ssh to my local machine. 我想通过ssh将此远程git repo克隆到本地计算机。 How? 怎么样?

I have tried git clone ssh://user@ipaddress:22/path/to/repo . 我已经尝试过git clone ssh://user@ipaddress:22/path/to/repo . but I get: 但我得到:

    Cloning into '.'...
    Permission denied (publickey).
    fatal: Could not read from remote repository.

I don't understand why this is because my ssh config file correctly specifies the IdentityFile and Hostname and normal ssh works fine with these settings. 我不明白为什么这是因为我的ssh配置文件正确指定了IdentityFileHostname而普通的ssh在这些设置下工作正常。

Any ideas? 有任何想法吗? Thanks. 谢谢。

Setting the environment variable GIT_TRACE to something else than 0 will make git output the expansion of aliases, and delegation to other sub-programs. 将环境变量GIT_TRACE设置为0以外的值将使git输出别名的扩展,并委托给其他子程序。

This will allow you to see the exact command git uses to ssh to your remote machine. 这将使您看到git用于ssh到远程计算机的确切命令。

In any case, here, the message is pretty clear: Permission denied (publickey). 无论如何,这里的信息非常清楚: Permission denied (publickey). This comes from ssh for sure, so if a normal ssh works fine, you need to find the difference between what you call a normal ssh and, the ssh that git is executing. 这肯定来自ssh,因此,如果正常的ssh可以正常工作,则需要查找所谓的正常ssh与git正在执行的ssh之间的区别。

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

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