3

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. 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:

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?

Oleksandr Verhun
  • 814
  • 1
  • 8
  • 23

1 Answers1

2

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.

YourRepo should be the name or the full path of the repo you want to clone.
I doubt your repo is named stranger@gmail.com.


The other issues are:

  • the name of the config file:
    no extension needed: ~/.ssh/config only. Anything else will be ignored by 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).
    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).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • When I do this, the following things that I get are: "no address associated with name" from ssh and then fatal "couln't read from repository" – Oleksandr Verhun Mar 22 '14 at 15:46
  • @user3130843 is your config file in the right place? `~/.ssh/config` – VonC Mar 22 '14 at 15:48
  • I added it in 2 places ~/.ssh/config.txt and ~/.ssh/config/config.txt to make sure, is this wrong? – Oleksandr Verhun Mar 22 '14 at 15:51
  • @user3130843 I confirm: no extension needed: `~/.ssh/config` only. Anything else **will be ignored** by ssh. – VonC Mar 22 '14 at 15:51
  • So there shouldn't be any other problems? – Oleksandr Verhun Mar 22 '14 at 15:53
  • @user3130843 see examples of that approach used in http://stackoverflow.com/a/9633439/6309, or http://stackoverflow.com/a/9551540/6309, or http://stackoverflow.com/a/16897818/6309 – VonC Mar 22 '14 at 15:54
  • @user3130843 the other issue is 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). 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`) – VonC Mar 22 '14 at 15:56
  • I'll think about your words, cause it still doesn't work.But to be sure, could the problem be, that the path to keys are in non-latin symbols? – Oleksandr Verhun Mar 22 '14 at 16:30
  • @user3130843 sure: it is better if the path is a standard one, with standard characters. And no '@' anywhere. – VonC Mar 22 '14 at 16:31
  • @user3130843 any time. I have edited the answer to include the issues detected so far, for more visibility. – VonC Mar 22 '14 at 16:38