# ssh username environment variable

4 messages from 2010-01-08 to 2010-01-08. Participants: Chris Packham, Shawn O. Pearce, Junio C Hamano.
Thread: https://gitlist.dev/t/22133

## Chris Packham, 2010-01-08 20:24

Subject: ssh username environment variable
Message-ID: <a038bef51001081224l33164526y51e5ca064b82b73a@mail.gmail.com>
URL: https://gitlist.dev/e/a038bef51001081224l33164526y51e5ca064b82b73a%40mail.gmail.com

```
Hi List,

Just wondering if there is an environment variable I can use to tell
git or ssh what user name to use for the ssh transport?

I would normally use
  git clone ssh://myname@example.com/repo.git

but I'm cloning to a relatively public network drive  (corporate
overlords don't want git no mater what I say) so I want to do
something like
  GIT_SSH_USER=myname  git clone ssh://example.com/repo.git

So that my user name doesn't show in the resulting remote.origin.url

I know I can probably just remove my user name from the config after
the the fact but I have to do this for a few repos so I thought I'd
ask if there was a magic environment variable I could set.

Thanks.

```

## Shawn O. Pearce, 2010-01-08 20:29

Subject: Re: ssh username environment variable
Message-ID: <20100108202958.GL32155@spearce.org>
URL: https://gitlist.dev/e/20100108202958.GL32155%40spearce.org
In-Reply-To: <a038bef51001081224l33164526y51e5ca064b82b73a@mail.gmail.com>

```
Chris Packham <judge.packham@gmail.com> wrote:
> Just wondering if there is an environment variable I can use to tell
> git or ssh what user name to use for the ssh transport?

No.  But you can hack around it:

  cat >$HOME/bin/git-ssh
  #!/bin/sh
  ssh -l $GIT_SSH_USER "$@"
  ^D

  GIT_SSH=$HOME/bin/git-ssh GIT_SSH_USER=myname git clone ...

-- 
Shawn.

```

## Junio C Hamano, 2010-01-08 20:34

Subject: Re: ssh username environment variable
Message-ID: <7vskag9vz0.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vskag9vz0.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20100108202958.GL32155@spearce.org>

```
"Shawn O. Pearce" <spearce@spearce.org> writes:

> Chris Packham <judge.packham@gmail.com> wrote:
>> Just wondering if there is an environment variable I can use to tell
>> git or ssh what user name to use for the ssh transport?
>
> No.  But you can hack around it:
>
>   cat >$HOME/bin/git-ssh
>   #!/bin/sh
>   ssh -l $GIT_SSH_USER "$@"
>   ^D
>
>   GIT_SSH=$HOME/bin/git-ssh GIT_SSH_USER=myname git clone ...

I thought the standard answer was "use $HOME/.ssh/config", to set User
by keying on the remote hostname to which you are going.

```

## Chris Packham, 2010-01-08 20:37

Subject: Re: ssh username environment variable
Message-ID: <a038bef51001081237h67fd421cg767403bf9f0d99df@mail.gmail.com>
URL: https://gitlist.dev/e/a038bef51001081237h67fd421cg767403bf9f0d99df%40mail.gmail.com
In-Reply-To: <7vskag9vz0.fsf@alter.siamese.dyndns.org>

```
On Fri, Jan 8, 2010 at 3:34 PM, Junio C Hamano <gitster@pobox.com> wrote:
> "Shawn O. Pearce" <spearce@spearce.org> writes:
>
>> Chris Packham <judge.packham@gmail.com> wrote:
>>> Just wondering if there is an environment variable I can use to tell
>>> git or ssh what user name to use for the ssh transport?
>>
>> No.  But you can hack around it:
>>
>>   cat >$HOME/bin/git-ssh
>>   #!/bin/sh
>>   ssh -l $GIT_SSH_USER "$@"
>>   ^D
>>
>>   GIT_SSH=$HOME/bin/git-ssh GIT_SSH_USER=myname git clone ...
>
> I thought the standard answer was "use $HOME/.ssh/config", to set User
> by keying on the remote hostname to which you are going.
>

Yeah thats what I've done after reading a few more man pages.

```
