简体   繁体   English

使用ssh访问存储库

[英]access repository with ssh

Yesterday I found out about existence of such thing as git.I need to access a remote repository with ssh.I used command $ git clone git@forest.com:stranger@gmail.com . 昨天我发现了$ git clone git@forest.com:stranger@gmail.com这样的东西的存在。我需要使用ssh访问一个远程存储库。我使用命令$ git clone git@forest.com:stranger@gmail.com But when I use this , it says it's cloning and then requires a password. 但是当我使用它时,它说它是克隆然后需要密码。 Though I have secret and pub keys in ~/.ssh.And also I have a config file, that looks like this: 虽然我在〜/ .ssh中有秘密和发布密钥。我也有一个配置文件,看起来像这样:

Host forest
    User git
    HostName forest.com
    Port 22
    IdentityFile ~/.ssh/<stranger@gmail.com>.key

Can you ppl give me a tip, how can I access this remote repository and why I need this config file, and what can I do with it? 你能不能给我一个提示,如何访问这个远程存储库以及为什么我需要这个配置文件,我该怎么办呢?

Since your key has no standard name, you need to use your config file. 由于您的密钥没有标准名称,因此您需要使用配置文件。
But the exact url for that would be: 但确切的网址是:

git clone forest:yourRepo

The key " forest " reference the Host entry in your ~/.ssh/config file, which will provide ssh with the right user, hostname, port and private key file to use. 密钥“ forest ”引用~/.ssh/config文件中的Host条目,该文件将为ssh提供要使用的正确用户,主机名,端口和私钥文件。

YourRepo should be the name or the full path of the repo you want to clone. YourRepo应该是要克隆的repo的名称或完整路径。
I doubt your repo is named stranger@gmail.com . 我怀疑你的回购被命名为stranger@gmail.com


The other issues are: 其他问题是:

  • the name of the config file : 配置文件的名称
    no extension needed: ~/.ssh/config only. 无需扩展名: ~/.ssh/config only。 Anything else will be ignored by ssh. ssh会忽略其他任何内容。

  • the name of your private key : 私钥的名称
    I strongly suggests avoiding the ' @ ' in it, and using a full path : /home/myName/.ssh/myKey and /home/myName/.ssh/myKey.pub (for private and public keys). 我强烈建议避免使用' @ ',并使用完整路径/home/myName/.ssh/myKey/home/myName/.ssh/myKey.pub (用于私钥和公钥)。
    Then your IdentityFile should reference the key without any extension : /home/myName/.ssh/myKey : that is the private one (as opposed to the public one: /home/myName/.ssh/myKey.pub ). 然后你的IdentityFile应该引用没有任何扩展名的密钥: /home/myName/.ssh/myKey :这是私有的(而不是公共的: /home/myName/.ssh/myKey.pub )。

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

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