# GIT over ssh with identity file

4 messages from 2009-02-04 to 2009-02-04. Participants: oliverw, Junio C Hamano, Matthieu Moy.
Thread: https://gitlist.dev/t/17547

## oliverw, 2009-02-04 08:37

Subject: GIT over ssh with identity file
Message-ID: <21826348.post@talk.nabble.com>
URL: https://gitlist.dev/e/21826348.post%40talk.nabble.com

```

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://homer@foo.bar.com/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.

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

```

## Junio C Hamano, 2009-02-04 08:41

Subject: Re: GIT over ssh with identity file
Message-ID: <7vbpti1tnd.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vbpti1tnd.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <21826348.post@talk.nabble.com>

```
oliverw <oliver@weichhold.com> writes:

> 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://homer@foo.bar.com/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

```

## Matthieu Moy, 2009-02-04 08:50

Subject: Re: GIT over ssh with identity file
Message-ID: <vpqhc3aa8m0.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqhc3aa8m0.fsf%40bauges.imag.fr
In-Reply-To: <7vbpti1tnd.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

>     $ 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).

-- 
Matthieu

```

## Junio C Hamano, 2009-02-04 09:25

Subject: Re: GIT over ssh with identity file
Message-ID: <7veiyezh8t.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7veiyezh8t.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <vpqhc3aa8m0.fsf@bauges.imag.fr>

```
Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>>     $ 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.

```
