LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   Restricting multiple username password prompts - Linux Mercurial Keyring extension (http://www.linuxquestions.org/questions/linux-software-2/restricting-multiple-username-password-prompts-linux-mercurial-keyring-extension-4175428262/)

sangal_ak04 09-20-2012 02:41 PM

Restricting multiple username password prompts - Linux Mercurial Keyring extension
 
Hi

I'm working on in setting up Mercurial Version control DVCS tool on Linux machine. It's done. When I go to http://server:port/hg

the link is working and whatever repositories I have created are visible and working fine.

Now, as a developer, when I access Mercurial repositories for doing development, like do "hg clone (checkout), hg commit, hg push etc).. I get prompted every time to provide my Active Directory/LDAP credentials when I do such operations.

I found mercurial can be configured with a plugin called "mercurial_keyring" and then, it'll just prompt the user his/her username/password (Active Directory / LDAP) for the first time and until that session remains, user can do any Hg/Mercurial development operations.

Does anyone have any information what file/setting I should change to make this happen correctly. So far, I have configured it per the online "mercurial_keyring" installation procedures but with no luck.

Following is my Linux user's ~/.hgrc file:
==========================================
Code:

[ui]
username=c123456 <Arun.Sangal@MyCompany.com>

[extensions]
mercurial_keyring = /root/mercurial_keyring.py

#[trusted]
#users = *
#groups = *

[extensions]
acl =
bugzilla =
children =
churn =
color =
convert =
eol = !
extdiff =
factotum = !
fetch =
gpg =
graphlog =
hgcia =
hgcr-gui-qt = !
hgk =
highlight =
interhg =
keyword =
largefiles = !
mercurial_keyring =
mq =
notify =
pager =
patchbomb =
perfarce = !
progress =
projrc = !
purge =
rebase =
record =
relink =
schemes =

.... ........etc

--------------------------------------------



My local Linux folder "Giga" where I hg cloned a repository has the following hgrc file contents inside: ../../Giga/.hg/hgrc):

---------------------------------------------

Code:

[paths]
default = http://the.hg.server.com/hg/TestHgRepo1/
myrepo = http://the.hg.server.com/hg/TestHgRepo1/

[auth]
myrepo.schemes = http https
myrepo.prefix = the.hg.server.com/hg
myrepo.username = c123456

---------------------------------------------

Any help.

sangal_ak04 01-10-2013 09:02 PM

1. Follow this link: http://pypi.python.org/pypi/mercurial_keyring

It's not that clear, but here's the main point.

when the above link says... use myremote, that means, while doing hg clone http://..../../repo1 <aliasname>
the aliasname MUST be given so that it'll checkout/clone your repo1 as "aliasname" given. then, there are 2 choices,

either update your local (instead of actual repository's .hg/hgrc file, NOTE this is different file that ~/.hgrc) --- or just update ~/.hgrc with the following lines


Quote:

[auth]
myremote.schemes = http https
myremote.prefix = ServerName/hg
myremote.username = c149807





1. NOTE NOTE:
1. While running "hg clone http://ServerName/some/hg/path/repos/Repository123" you have to provide another parameter, <aliasname> for the cloned "Repository123" folder/repository i.e.

hg clone http://ServerName/some/hg/path/repos/Repository123 myremote

what the above command will do is.. it'll checkout/clone Repository123 as "myremote" on the folder location from where you ran the above command. NOBODY mentioned this in the MERCURIAL KEYRING documentation clearly.

Now,

change some file.
do: hg stat
do: hg commit -m "somecomments"
(if you dont do this and do hg out/push directly, you'll see an error "No changes found")
do: hg out
do: hg push

NOW, NO MORE Multiple prompts for user authentication by Mercurial LDAP authentication at the prompt or in TortoiseHg.


2. NOTE NOTE: Make sure whatever ServerName you use, either just
ServerName
or
ServerName.company.com
or
ServerName.domain.company.com
or
xx.xx.xx.xx
i.e. Server's IP, in the hg clone command, you have to make sure that the value you'll put in ~/.hgrc (home directory's .hgrc file, which is different than repository's local .hg/hgrc file)... should have the 2nd line (value for remote server) as the same value that you used during clone command 1st parameter (http://<servervalue>)

Quote:

[auth]
myremote.schemes = http https
myremote.prefix = ServerName/hg
myremote.username = c149807
or

Quote:

[auth]
myremote.schemes = http https
myremote.prefix = ServerName.company.com/hg
myremote.username = c149807
or

Quote:

[auth]
myremote.schemes = http https
myremote.prefix = ServerName.domain.company.com/hg
myremote.username = c149807
or

Quote:

[auth]
myremote.schemes = http https
myremote.prefix = xx.xx.xx.xx/hg
myremote.username = c149807

otherwise, MERCURIAL KEYRING extension won't work.


easy peasy !!

sangal_ak04 01-10-2013 09:30 PM

PS these links: for solutions on similar issues

http://stackoverflow.com/questions/1...69997#14269997
http://www.linuxquestions.org/questi...12#post4867412
http://stackoverflow.com/questions/1...70602#14270602
http://stackoverflow.com/questions/1...70648#14270648

sangal_ak04 01-16-2013 12:43 PM

if prompted multiple times for user credentials in mercurial. Setup Mercurial_Keyring and then

this question comes which nobody explained in an easy way.

??? how to make the [auth] xx.prefix = servername/hg_or_something work for all repositories under servername/hg location either if I use servername, servername's IP or servername's FQDN ?

ANSWER: Arun • 2 minutes ago −

OK, I put this in ~/.hgrc (Linux/Unix -home directory's .hgrc hidden file) or Windows users %UserProfile%/mercurial.ini or %HOME%/mercurial.ini file.

[auth]
default1.schemes = http https
default1.prefix = hg_merc_server/hg
default1.username = c123456

default2.schemes = http https
default2.prefix = hg_merc_server.company.com/hg
default2.username = c123456

default3.schemes = http https
default3.prefix = 10.211.222.321/hg
default3.username = c123456

Now, I can checkout using either Server/IP/Server's FQDN.


All times are GMT -5. The time now is 03:45 PM.