Skip to contentSkip to conversation

GIT over ssh with identity file

DISCUSSION oliverw 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore

oliverw

author
#0 lore raw

Forgive me if this has been answered before. I've searched everywhere but couldn't find a solution.

Is it somehow possible to pass your private key file to git when working over ssh. What I have in mind would be something like this:

git -i /path/to/private/key clone ssh://[email protected]/var/git/repos.git

Since I want to use this on a server I would like to avoid using a password caching agent at all cost.

Signature · 2 lines
View this message in context: http://www.nabble.com/GIT-over-ssh-with-identity-file-tp21826348p21826348.html
Sent from the git mailing list archive at Nabble.com.
#1 lore raw
Quoted 7 lines · oliverw

Forgive me if this has been answered before. I've searched everywhere but couldn't find a solution.

Is it somehow possible to pass your private key file to git when working over ssh. What I have in mind would be something like this:

git -i /path/to/private/key clone ssh://[email protected]/var/git/repos.git

I think the standard way people use for things like this is something along the lines of...

    $ cat >>$HOME/.ssh/config <<\EOF
    Host homer-at-foo
      Hostname foo.bar.com
      User homer
      IdentityFile ~/.ssh/homer-at-foo.pub
    EOF
    $ git clone homer-at-foo:/var/git/repos.git
#2 lore raw
Quoted 5 lines · Junio C Hamano
    $ cat >>$HOME/.ssh/config <<\EOF
    Host homer-at-foo
      Hostname foo.bar.com
      User homer
      IdentityFile ~/.ssh/homer-at-foo.pub

(I think you have an extra .pub here, the identity file should be the private key).

Signature · 1 line
Matthieu
#3 lore raw
Quoted 10 lines · Matthieu Moy
Quoted 5 lines · Junio C Hamano
    $ cat >>$HOME/.ssh/config <<\EOF
    Host homer-at-foo
      Hostname foo.bar.com
      User homer
      IdentityFile ~/.ssh/homer-at-foo.pub

(I think you have an extra .pub here, the identity file should be the private key).

Yeah, you are right. I am too tired and should have gone to bed 90 minutes ago.