Repo command-- having a different username on server than my machine

7,824 views
Skip to first unread message

Propane13

unread,
Nov 28, 2011, 1:36:34 PM11/28/11
to Repo and Gerrit Discussion
Hello!

Let's say that I have a gerrit server set up such that it registers
users through LDAP accounts.
Unfortunately, my LDAP account is different from my own personal
computer username.

I can clone a manifest really easy with:
repo init -u ssh://<my_ldap_username>@<gerrit_server>:29418/manifest.git

However, once I have the manifest cloned, I'm going to experience a
problem on the repo sync.

Here's my basic manifest info:
<remote name="my_remote"
fetch="ssh://<gerrit_server>:29418" />

If I do a repo sync, I'll end up fetching using my personal computer
login name, which will fail due to key mismatches.

I can get around this by making myself a personal branch for the
manifest that has my LDAP username, i.e.:
<remote name="my_remote"
fetch="ssh://<my_ldap_username>@<gerrit_server>:29418" />

But, this isn't so nice, because I have to maintain a branch every
time the repo list changes.

I was thinking it would be nice to set things as so:
<remote name="my_remote"
fetch="ssh://$BASHALIAS@<gerrit_server>:29418" />

and then I can have users all define BASHALIAS in their .bashrc.

However, this doesn't seem to work-- I am guessing because the fetch
string is evaluated as a literal, and therefore the alias doesn't go
through.

Has anyone else had any way around this? Maybe there's some simple
git config that I'm not thinking of to force my username to always be
my LDAP username, instead of my PC's default username.
I'm aware of user.name and user.email, but is there another one that I
can use? user.name seems to be for my full name.

Any thoughts?

Regards,
-John

Magnus Bäck

unread,
Nov 28, 2011, 1:49:27 PM11/28/11
to Repo and Gerrit Discussion
On Monday, November 28, 2011 at 19:36 CET,
Propane13 <johnk...@gmail.com> wrote:

> Let's say that I have a gerrit server set up such that it registers
> users through LDAP accounts.
> Unfortunately, my LDAP account is different from my own personal
> computer username.
>
> I can clone a manifest really easy with:
> repo init -u ssh://<my_ldap_username>@<gerrit_server>:29418/manifest.git
>
> However, once I have the manifest cloned, I'm going to experience a
> problem on the repo sync.
>
> Here's my basic manifest info:
> <remote name="my_remote"
> fetch="ssh://<gerrit_server>:29418" />
>
> If I do a repo sync, I'll end up fetching using my personal computer
> login name, which will fail due to key mismatches.

Either use an insteadOf block in your ~/.gitconfig,

[url "ssh://username@hostname:29418/"]
insteadOf = ssh://hostname:29418/

or (preferably)

Host hostname
User username
Port 29418

in your ~/.ssh/config. The latter has the advantage that it works
not only when fetching code with git but in any circumstances when
you want to connect to Gerrit via SSH, i.e. you can say

git push ssh://hostname/path/to/git
or
ssh hostname gerrit ls-projects

instead of repeating the username and port information there too.

[...]

--
Magnus Bäck Opinions are my own and do not necessarily
SW Configuration Manager represent the ones of my employer, etc.
Sony Ericsson

Propane13

unread,
Nov 28, 2011, 4:03:34 PM11/28/11
to Repo and Gerrit Discussion
This solution worked perfectly. Thanks much!

-John

Reply all
Reply to author
Forward
0 new messages