LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-19-2012, 12:37 PM   #1
Cyrolancer
Member
 
Registered: Jan 2012
Distribution: Debian
Posts: 52

Rep: Reputation: Disabled
Same username but different uids


Hello,

I am trying to implement a login system one of my client's server. There will be a web access and a console access for the same user.

For the web interface, I have built a PHP-MySQL based system. For the console login, I have implemented PAM-MySQL and NSS-MySQL to use my user database created by the web system.

My client requested me to do something different. They are going to use 2 domains, for example example1.com and example2.com. The person who can login to example1.com will not login to example2.com. A person can register to example1.com with an username of "cyro" and also another person can register example2.com with "cyro". These users should be different, because they are registered under different domain names. But all users will be hosted in the same database with different user ids. For example, cyro user of example1.com has an user id of 5000 and cyro user of example2.com has an user id of 5500.

Is it possible to store same username with different user ids and enable console access (using SSH) seperately for both "cyro" accounts?

I know it sounds silly and as far as I know, Linux accounts doesn't work like the way my client wants but I just want to know the possibility. You can just say "it is impossible" and that would be OK for me.

Thanks
 
Old 02-19-2012, 02:11 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi Cyrolancer,

Interesting requirement from the client :-)

As I can understand you have got two domains. One is example1.com and other is example2.com. There is a common database which keeps record of users from both domains. Now you want that users from example1.com should only be able to ssh/connect to the machines from example1.com and they should not have any access to machines from example2.com either via ssh/other methods. Is that correct?

It is not possible if linux is referring local authentication (/etc/passwd) because you cannot have two users with the same userid. I am pretty sure that you have configured your linux to use the database which you have created for authentication. Am I right? If that is the case then you can make use of the mechanism that LDAP uses that is identifying the user via distinguised name. Here is how it works:

I have created a user say cyro under users container in example1.com. Then dn for this user will be dn: cn=cyro,ou=users,ou=example1,o=com. Similary, if I create another user with the same name under users container in example2.com then his dn will be dn: cn=cyro,ou=users,ou=example2,o=com

The above is an example how LDAP searches for a users. I have no idea how you will implement that with your database. But this is one way you can achieve what you are looking for. Provided you make it work :-)
 
Old 02-19-2012, 02:28 PM   #3
Cyrolancer
Member
 
Registered: Jan 2012
Distribution: Debian
Posts: 52

Original Poster
Rep: Reputation: Disabled
Hello T3RM1NVT0R,

Thank you for your answer.

Quote:
As I can understand you have got two domains. One is example1.com and other is example2.com. There is a common database which keeps record of users from both domains. Now you want that users from example1.com should only be able to ssh/connect to the machines from example1.com and they should not have any access to machines from example2.com either via ssh/other methods. Is that correct?
That is correct.

Quote:
It is not possible if linux is referring local authentication (/etc/passwd) because you cannot have two users with the same userid. I am pretty sure that you have configured your linux to use the database which you have created for authentication. Am I right?
You are completely correct. I am using PAM-MySQL and NSS-MySQL to get user info from MySQL database, having unique UID, GID and username. In my client's case, UID and GID will be unique but username will not.

Quote:
If that is the case then you can make use of the mechanism that LDAP uses that is identifying the user via distinguised name. Here is how it works:

I have created a user say cyro under users container in example1.com. Then dn for this user will be dn: cn=cyro,ou=users,ou=example1,o=com. Similary, if I create another user with the same name under users container in example2.com then his dn will be dn: cn=cyro,ou=users,ou=example2,o=com

The above is an example how LDAP searches for a users. I have no idea how you will implement that with your database. But this is one way you can achieve what you are looking for. Provided you make it work :-)
I have worked with LDAP before using MySQL for user database. Using default debian configuration, you need to setup a static DN for PAM and NSS utilities. I don't know it is possible to define;

if user is coming from example1.com
use ou=users,dc=example1,dc=com on ldap-server1
else if user is coming from example2.com
use ou=users,dc=example2,dc=com on ldap-server1
else
use mysql database

(Note that, both LDAP connections to ldap-server1)

For me, LDAP is not simple to use. I know it is a high performance database for use with login systems. Even Active Directory of M$ uses an implementation of LDAP. I have managed several systems under one domain controller but having 2 separate domains under Windows, but I don't know PAM can handle such implementation.
 
Old 02-20-2012, 01:22 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

I gave some more thought on this scenario and it appears like it will not be possible to use the same username. Even if you think of ldap contextless login then also system will get confused as to which context user to pick up.

Unless we have mechanism in place that will ask the users to enter full dn and then authenticate. Without that this does not look achievable because we are confusing the system as to which user to pick up.
 
Old 02-20-2012, 02:04 PM   #5
Cyrolancer
Member
 
Registered: Jan 2012
Distribution: Debian
Posts: 52

Original Poster
Rep: Reputation: Disabled
What about Kerberos authentication with LDAP? I think we can assign realms in Kerberos method but is it possible to login to same server, with using different realms? (I think, different realms mean different users but we can have the same username for these different realms. The users with the same username are not pointing to the same account.)

Sounds complicated. Hope I explained well.
 
Old 02-20-2012, 03:07 PM   #6
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Kerberos realm is same as that of domain in Windows and context in ldap. And it is used to basically enhance the security. How that will help in this scenario? As you said earlier you are looking for something like this:

Quote:
As I can understand you have got two domains. One is example1.com and other is example2.com. There is a common database which keeps record of users from both domains. Now you want that users from example1.com should only be able to ssh/connect to the machines from example1.com and they should not have any access to machines from example2.com either via ssh/other methods. Is that correct?
This will only be possible in the following scenarios:

1. You have seperate database for both domains.
2. If the above is not possible then making user to type in username in the form of dn. That is the only way I can think if you want to differentiate two users in a common database.

Thing that is a challenge is how system will uniquely identify the user on the network. I am not aware of any method other than the 2 I have mentioned above. Even somehow we make the system to perform a search of a particular user from top level then also it will get confuse when it will come to username as to which one to pick the one in users.example1.com or users.example2.com.
 
Old 02-20-2012, 03:37 PM   #7
Cyrolancer
Member
 
Registered: Jan 2012
Distribution: Debian
Posts: 52

Original Poster
Rep: Reputation: Disabled
I have though setting up different realms can solve this issue. Still doing some research on it, but I have found nothing up to now, as you said. Maybe, somehow, we could set up a SSH login name as cyro@example1.com, then the things would work.

According to my research on your suggestions, it is not possible to set multiple DNs for use in pam-ldap module. Or is it possible somehow?
 
Old 02-21-2012, 06:10 AM   #8
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Quote:
Originally Posted by T3RM1NVT0R View Post
It is not possible if linux is referring local authentication (/etc/passwd) because you cannot have two users with the same userid.
I don’t agree. This is possible and each of them can have his/her own home but they can also access/change the other user’s home due to the same uid.
 
Old 02-21-2012, 07:22 AM   #9
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
AFAICS there is at least a “where” clause for PAM-MySQL, and it looks like a custom query could be constructed for NSS-MySQL too. Then it should be possible to have an additional field for the server (i.e. domain) in the database to which this one this entry applies.
 
Old 02-21-2012, 01:45 PM   #10
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

@ Reuti,

Quote:
I don’t agree. This is possible and each of them can have his/her own home but they can also access/change the other user’s home due to the same uid.
How you can do that? Are you talking about directly editing /etc/passwd? Or is there another way to do that? Even if that is possible I do not see any point in confusing the system as to which id we want him to login the user with. Here I am only talking about /etc/passwd authentication, no other authentication method involved.
 
Old 02-21-2012, 02:11 PM   #11
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Code:
# useradd -u 2222 -g 100 demo1
# useradd -o -u 2222 -g 100 demo2
# id demo1
uid=2222(demo1) gid=100(users) groups=100(users),16(dialout),33(video)
# id demo2
uid=2222(demo1) gid=100(users) groups=100(users),16(dialout),33(video)
For listing the user in ls -l or the above id command, it will just show one of them. Nevertheless both have different home directories and different passwords.

But this won’t help the OP, as he wants the opposite.
 
Old 02-21-2012, 02:14 PM   #12
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Yes, OP is asking for same userid but different UID. And I am not aware of creating two users with same userid.
 
Old 02-21-2012, 02:23 PM   #13
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Obviously a misunderstanding: for me UID and userid is the same, therefore I was answering - the numerical identifier of the defined username. Also man useradd explains -u with setting the userid to the specified number.
 
Old 02-23-2012, 01:30 AM   #14
Cyrolancer
Member
 
Registered: Jan 2012
Distribution: Debian
Posts: 52

Original Poster
Rep: Reputation: Disabled
It seems the question is solved.

Thank you for the information you have provided.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'ps aux' displays users as uids, instead of username SlowCoder Linux - Newbie 18 10-25-2012 10:29 AM
Faking uids eric.frederich Programming 9 12-10-2011 11:08 AM
two users with uids of 0 shanenin Linux - Security 2 03-04-2005 09:57 AM
How can I find and change UIDs k2merlinsix Linux - Networking 5 12-28-2004 03:15 PM
Help with UIDs please :) gponto18 Linux - Newbie 5 10-22-2002 02:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration