3

I am trying create an application which will clone the GIT repository to the computer. My question is how to clone the secured repository if the SSH keys are not in the default place.

I want to let people to upload keys and then with those keys to connect and clone the repository.

So to conclude: I do not want GIT to look for key on default places, I want to 'give' it the path to the key file, and then put it in command (along with passphrase if there is any) somehow and get cloned repository.

Thank you very much in advance!

Goran
  • 3,292
  • 2
  • 29
  • 32
  • 1
    “to upload keys” – are you serious? Are you talking about encouraging user to upload their private key? Users doing that obviously don’t know what they’re doing as they should keep their private key PRIVATE! Publishing it to whomever, transmitting it, is putting the authentication security at risk and pretty much negates any security measurements. I don’t know what you’re trying to do, but are you sure that is the way to go? – Kissaki Dec 01 '10 at 16:57
  • 1
    In the answer comments below you’re talking about realizing this in PHP, however you did not mention PHP in the question. Could you specify / elaborate that? Also, is it a PHP script executed locally, as you’re trying to make it to clone a repo to the (local?) computer!? – Kissaki Dec 01 '10 at 17:00

1 Answers1

4

It's not git who is looking, its SSH. You need to specify the keys in the .ssh/authorized_keys file, that is the public key btw. The private key will be stored on the users machine.

Šimon Tóth
  • 35,456
  • 20
  • 106
  • 151
  • Thank you very much for your answer. I have seen that SmartGit (OS X application) uses its own SSH client to connect with repositories. How can I create my own SSH client (p.s. it is an PHP application)? – Goran Dec 01 '10 at 15:54
  • @Goran The public keys are checked by the SSH server. You can build upon some existing SSH client: http://en.wikipedia.org/wiki/Comparison_of_SSH_clients – Šimon Tóth Dec 01 '10 at 15:57
  • I am afraid that you did not understood me. In SmartGit application all you need to do is to choose a private key and type in password, and it automatically connects to the git repository. That is exactly what I want to code but in PHP web application... Could you please help me with that? – Goran Dec 01 '10 at 16:13
  • @Goran But you don't need ssh client for that, git is enough. How this works is: `git client -> ssh client -> INTERNET -> ssh server -> git server` – Šimon Tóth Dec 01 '10 at 16:18
  • @ Let_Me_Be But still, I do not know how to login git repo with private key which is not in default place (lets say it is in /mykeys folder and I do not have permissions to copy/move it)... – Goran Dec 01 '10 at 16:27
  • @Goran Oooh, OK, that needs to be specified in `.ssh/config` – Šimon Tóth Dec 01 '10 at 16:32
  • @ Let_Me_Be Ok, thank you very much for the discussion. You have been very helpful!! We have decided to go the different way and only work with working trees (since usually we would not have access with PHP to .ssh folders). – Goran Dec 01 '10 at 16:58