LinuxQuestions.org
Visit Jeremy's Blog.
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-29-2012, 02:06 PM   #1
maksaraswat
LQ Newbie
 
Registered: Jul 2011
Posts: 15

Rep: Reputation: Disabled
SSH (PAM) Authentication for Domain User


Hi,

I have a CentOS configured with Samba and Winbind for file shares which works fine. In order for domain user to login to the linux box I did configure /etc/pam.d/sshd file. However every time I try to login with domain user it connects and shows the standard message "Last login: ..." and then disconnects by displaying message "Connection to the SERVER-NAME is closed."

Also, it did ask to manually create the /home/DOMAIN/ directory else it gives this message

"Last login: Tue Feb 28 16:30:45 2012 from x.x.x.x
Could not chdir to home directory /home/DOMAIN/USER: No such file or directory
Connection to SERVER closed."

The /etc/pam.d/sshd looks like this:

auth sufficient pam_winbind.so
auth required pam_nologin.so
auth include system-auth
account sufficient pam_winbind.so
account include system-auth
session include system-auth
password include system-auth

Following is the message at /var/log/secure (disregarding the break-in attempt part)

Feb 28 16:44:55 file3 sshd[4394]: reverse mapping checking getaddrinfo for machinename.domain.com failed - POSSIBLE BREAK-IN ATTEMPT!
Feb 28 16:44:59 file3 sshd[4394]: pam_winbind(sshd:auth): getting password (0x00000000)
Feb 28 16:44:59 file3 sshd[4394]: pam_winbind(sshd:auth): user 'DOMAIN+User' granted access
Feb 28 16:44:59 file3 sshd[4394]: pam_winbind(sshd:account): user 'DOMAIN+User' granted access
Feb 28 16:44:59 file3 sshd[4394]: Accepted password for DOMAIN+User from x.x.x.x port 44240 ssh2
Feb 28 16:44:59 file3 sshd[4394]: pam_unix(sshd:session): session opened for user DOMAIN+User by (uid=0)
Feb 28 16:44:59 file3 sshd[4396]: Received disconnect from x.x.x.x: 11: disconnected by user
Feb 28 16:44:59 file3 sshd[4394]: pam_unix(sshd:session): session closed for user DOMAIN+User

I have also added the group in sudoers list that will be accessing this machine.

Please can anyone assist me here to make ssh work for domain user.


Thanks in advance!
Mayank
 
Old 03-03-2012, 07:59 PM   #2
Cyrolancer
Member
 
Registered: Jan 2012
Distribution: Debian
Posts: 52

Rep: Reputation: Disabled
Did you assigned a shell, like /bin/bash, for the users?
 
Old 03-05-2012, 11:27 AM   #3
Beandip408
LQ Newbie
 
Registered: Aug 2011
Posts: 20

Rep: Reputation: Disabled
Quote:
Originally Posted by maksaraswat View Post
Hi,

I have a CentOS configured with Samba and Winbind for file shares which works fine. In order for domain user to login to the linux box I did configure /etc/pam.d/sshd file. However every time I try to login with domain user it connects and shows the standard message "Last login: ..." and then disconnects by displaying message "Connection to the SERVER-NAME is closed."

Also, it did ask to manually create the /home/DOMAIN/ directory else it gives this message

"Last login: Tue Feb 28 16:30:45 2012 from x.x.x.x
Could not chdir to home directory /home/DOMAIN/USER: No such file or directory
Connection to SERVER closed."

The /etc/pam.d/sshd looks like this:

auth sufficient pam_winbind.so
auth required pam_nologin.so
auth include system-auth
account sufficient pam_winbind.so
account include system-auth
session include system-auth
password include system-auth

Following is the message at /var/log/secure (disregarding the break-in attempt part)

Feb 28 16:44:55 file3 sshd[4394]: reverse mapping checking getaddrinfo for machinename.domain.com failed - POSSIBLE BREAK-IN ATTEMPT!
Feb 28 16:44:59 file3 sshd[4394]: pam_winbind(sshd:auth): getting password (0x00000000)
Feb 28 16:44:59 file3 sshd[4394]: pam_winbind(sshd:auth): user 'DOMAIN+User' granted access
Feb 28 16:44:59 file3 sshd[4394]: pam_winbind(sshd:account): user 'DOMAIN+User' granted access
Feb 28 16:44:59 file3 sshd[4394]: Accepted password for DOMAIN+User from x.x.x.x port 44240 ssh2
Feb 28 16:44:59 file3 sshd[4394]: pam_unix(sshd:session): session opened for user DOMAIN+User by (uid=0)
Feb 28 16:44:59 file3 sshd[4396]: Received disconnect from x.x.x.x: 11: disconnected by user
Feb 28 16:44:59 file3 sshd[4394]: pam_unix(sshd:session): session closed for user DOMAIN+User

I have also added the group in sudoers list that will be accessing this machine.

Please can anyone assist me here to make ssh work for domain user.


Thanks in advance!
Mayank
where are the domain users credentials? are they stored in Active Directory? and if so, is it Windows Server 2008?
 
Old 03-06-2012, 03:20 PM   #4
yngmike
LQ Newbie
 
Registered: Sep 2007
Posts: 10

Rep: Reputation: 2
You will want to check and see if /etc/security/access.conf is configured properly. Make sure + : ALL : ALL is called out (if you are not concerned about security. You will need to tighten this up later).
as well as check /etc/securetty (if a valid tty for the user is not defined you can login, but it will immediately disconnect you).

Hope that helps.
 
Old 03-07-2012, 04:05 PM   #5
maksaraswat
LQ Newbie
 
Registered: Jul 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
@Cyrolance: I am not sure where to assign that however in the system-auth file I have following line:
session optional pam_mkhomedir.so umask=0077

@Beandip408: Yes, its on AD which is a 2008 R2 box.

@yngmike: I added + : ALL = ALL but its still disconnecting. Also, I don't want to add a tty in the securetty as I need a group of people to access the boxes not just one.

I really appreciate everyone helping out here!

Thanks,
Mayank
 
Old 03-07-2012, 05:06 PM   #6
manyrootsofallevil
Member
 
Registered: Dec 2010
Distribution: Red Hat, Kubuntu
Posts: 130

Rep: Reputation: 14
what version of CentOS are you using?

If you do

Code:
getent passwd
Do you get a list of domain users? Only domain users that have Unix Settings will show up

I have written a guide to join a CentOS 6 /RHEL6 box to a Windows 2008 AD domain
 
1 members found this post helpful.
Old 03-08-2012, 02:14 AM   #7
Cyrolancer
Member
 
Registered: Jan 2012
Distribution: Debian
Posts: 52

Rep: Reputation: Disabled
Quote:
Originally Posted by maksaraswat View Post
@Cyrolance: I am not sure where to assign that however in the system-auth file I have following line:
session optional pam_mkhomedir.so umask=0077
That's not the case. Maybe you need to install something like "Microsoft Services for Unix" to the Windows Server. Linux needs UID, GID, Home Directory and Login Shell in order to continue after the login process. I think, you have set up the login, Linux checks the AD for password and username, then says OK. But when Linux asks for other things, like Home Directory or Login Shell, AD does not respond or responds like "not found" and you disconnect from the Linux.

The directive "pam_mkhomedir" needs a valid Home Directory and creates it if not available. You can set /home/test or /var/www/test, it does not matter for "pam_mkhomedir". It just creates the directory if not present in the filesystem.

Last edited by Cyrolancer; 03-08-2012 at 02:15 AM.
 
Old 03-09-2012, 07:30 AM   #8
yngmike
LQ Newbie
 
Registered: Sep 2007
Posts: 10

Rep: Reputation: 2
Quote:
Originally Posted by Cyrolancer View Post
That's not the case. Maybe you need to install something like "Microsoft Services for Unix" to the Windows Server. Linux needs UID, GID, Home Directory and Login Shell in order to continue after the login process. I think, you have set up the login, Linux checks the AD for password and username, then says OK. But when Linux asks for other things, like Home Directory or Login Shell, AD does not respond or responds like "not found" and you disconnect from the Linux.

The directive "pam_mkhomedir" needs a valid Home Directory and creates it if not available. You can set /home/test or /var/www/test, it does not matter for "pam_mkhomedir". It just creates the directory if not present in the filesystem.
@Cyrolancer,

That is incorrect. Microsoft services for Unix would only be required if you defined RFC2307 extensions in your smb.conf

IE:

winbind nss info = rfc2307
idmap config YOURDOMAIN : cache time = 1800
idmap config YOURDOMAIN : backend = ad
idmap config YOURDOMAIN : range = 10000-5000000
idmap config YOURDOMAIN : schema_mode = rfc2307

Additionally some tweaks with ADSI edit would also be required.


If he is getting disconnected immediately after login, it would seem to me that he is having some type of PAM issue.
 
1 members found this post helpful.
Old 03-09-2012, 07:53 AM   #9
Cyrolancer
Member
 
Registered: Jan 2012
Distribution: Debian
Posts: 52

Rep: Reputation: Disabled
Quote:
Originally Posted by yngmike View Post
@Cyrolancer,

That is incorrect. Microsoft services for Unix would only be required if you defined RFC2307 extensions in your smb.conf

IE:

winbind nss info = rfc2307
idmap config YOURDOMAIN : cache time = 1800
idmap config YOURDOMAIN : backend = ad
idmap config YOURDOMAIN : range = 10000-5000000
idmap config YOURDOMAIN : schema_mode = rfc2307

Additionally some tweaks with ADSI edit would also be required.
Thank you for the correction yngmike. I think the link provided by manyrootsofallevil may solve the problem. I missed it before posting.
 
Old 03-12-2012, 02:26 PM   #10
maksaraswat
LQ Newbie
 
Registered: Jul 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Thanks everyone for the replies.

@manyrootsofallevil: We are using AD with Linux integration from several years and I doubt we have any issues with the join. When I do wbinfo -u and wbinfo -g I get all the domain users and groups. Also getent passwd I see domain and local user details.

@Cyrolance: I am not sure where/how I can define a home directory pam_makehomedir


I am still working on it and trying to resolve it.


Thanks,
Mayank
 
Old 03-13-2012, 03:04 AM   #11
manyrootsofallevil
Member
 
Registered: Dec 2010
Distribution: Red Hat, Kubuntu
Posts: 130

Rep: Reputation: 14
Quote:
Originally Posted by maksaraswat View Post
Thanks everyone for the replies.

@manyrootsofallevil: We are using AD with Linux integration from several years and I doubt we have any issues with the join. When I do wbinfo -u and wbinfo -g I get all the domain users and groups. Also getent passwd I see domain and local user details.

@Cyrolance: I am not sure where/how I can define a home directory pam_makehomedir


I am still working on it and trying to resolve it.


Thanks,
Mayank
If your users are all logging in with SSH, you could add this directive to /etc/pam.d/sshd

Quote:
session required pam_mkhomedir.so skel=/etc/skel umask=0022
and remove the other mkhomedir reference form sys-auth, at least temporarily.

Change the umask to suit your needs.

Do make sure that it is the first session directive, though.

This works for CentOS/RHEL 6.x

The other thing to bear in mind, is what is the status of SELinux? The above will not work if SELinux is set to enforcing and you haven't created policy modules.
 
Old 03-13-2012, 09:57 AM   #12
yngmike
LQ Newbie
 
Registered: Sep 2007
Posts: 10

Rep: Reputation: 2
FYI: If you put

session required /lib64/security/pam_mkhomedir.so skel=/etc/skel umask=022

In /etc/pam.d/system-auth it will work for all logins, since system-auth is referenced by /etc/pam.d/sshd by default anyway.

SELINUX is a whole other can of works. Temporarily disable it for troublshooting.

-Mike
 
Old 03-14-2012, 02:40 PM   #13
maksaraswat
LQ Newbie
 
Registered: Jul 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
As soon as I try to ssh I see the following log in /var/log/secure

Mar 14 15:23:56 SERVERNAME sshd[13444]: PAM unable to dlopen(/lib64/security/system-auth)
Mar 14 15:23:56 SERVERNAME sshd[13444]: PAM [error: /lib64/security/system-auth: cannot open shared object file: No such file or directory]
Mar 14 15:23:56 SERVERNAME sshd[13444]: PAM adding faulty module: /lib64/security/system-auth
Mar 14 15:24:31 SERVERNAME sshd[13444]: pam_winbind(sshd:auth): getting password (0x00000000)

The above log is even before I enter password and as soon as I enter password I see following on my prompt

Last login: Wed Mar 14 15:22:48 2012 from X.X.X.X
Could not chdir to home directory /home/DOMAIN/username: No such file or directory
Connection to SERVERNAME closed.

And on server I see following in /var/log/secure


Mar 14 15:24:31 SERVERNAME sshd[13444]: pam_winbind(sshd:auth): getting password (0x00000000)
Mar 14 15:24:31 SERVERNAME sshd[13444]: pam_winbind(sshd:auth): user 'DOMAIN+username' granted access
Mar 14 15:24:31 SERVERNAME sshd[13444]: pam_winbind(sshd:account): user 'DOMAIN+username' granted access
Mar 14 15:24:31 SERVERNAME sshd[13444]: Accepted password for DOMAIN+username from X.X.X.X port XXXXX ssh2
Mar 14 15:24:31 SERVERNAME sshd[13446]: Received disconnect from X.X.X.X: 11: disconnected by user

I am not sure why it says disconnected by user as the user is trying to connect.

Thanks in advance!

Mayank
 
Old 03-15-2012, 02:55 AM   #14
manyrootsofallevil
Member
 
Registered: Dec 2010
Distribution: Red Hat, Kubuntu
Posts: 130

Rep: Reputation: 14
Quote:
Originally Posted by maksaraswat View Post
As soon as I try to ssh I see the following log in /var/log/secure

Mar 14 15:23:56 SERVERNAME sshd[13444]: PAM unable to dlopen(/lib64/security/system-auth)
Mar 14 15:23:56 SERVERNAME sshd[13444]: PAM [error: /lib64/security/system-auth: cannot open shared object file: No such file or directory]
Mar 14 15:23:56 SERVERNAME sshd[13444]: PAM adding faulty module: /lib64/security/system-auth
Mar 14 15:24:31 SERVERNAME sshd[13444]: pam_winbind(sshd:auth): getting password (0x00000000)

The above log is even before I enter password and as soon as I enter password I see following on my prompt

Last login: Wed Mar 14 15:22:48 2012 from X.X.X.X
Could not chdir to home directory /home/DOMAIN/username: No such file or directory
Connection to SERVERNAME closed.

And on server I see following in /var/log/secure


Mar 14 15:24:31 SERVERNAME sshd[13444]: pam_winbind(sshd:auth): getting password (0x00000000)
Mar 14 15:24:31 SERVERNAME sshd[13444]: pam_winbind(sshd:auth): user 'DOMAIN+username' granted access
Mar 14 15:24:31 SERVERNAME sshd[13444]: pam_winbind(sshd:account): user 'DOMAIN+username' granted access
Mar 14 15:24:31 SERVERNAME sshd[13444]: Accepted password for DOMAIN+username from X.X.X.X port XXXXX ssh2
Mar 14 15:24:31 SERVERNAME sshd[13446]: Received disconnect from X.X.X.X: 11: disconnected by user

I am not sure why it says disconnected by user as the user is trying to connect.

Thanks in advance!

Mayank
is your system 64 bit?

On our 64 bit system we don't bother with qualified names

Use

Code:
session required pam_mkhomedir.so skel=/etc/skel umask=0022
instead of

Code:
session required /lib64/security/pam_mkhomedir.so skel=/etc/skel umask=0022
@yngmike: We only login from SSH as our env is virtualized and we don't have access to vCentre. Obviously if this not the case, then system-auth is a better place to add this directive.

Last edited by manyrootsofallevil; 03-15-2012 at 02:58 AM.
 
Old 03-15-2012, 08:47 AM   #15
yngmike
LQ Newbie
 
Registered: Sep 2007
Posts: 10

Rep: Reputation: 2
You definately have a PAM issue.

Mar 14 15:23:56 SERVERNAME sshd[13444]: PAM unable to dlopen(/lib64/security/system-auth)
Mar 14 15:23:56 SERVERNAME sshd[13444]: PAM [error: /lib64/security/system-auth: cannot open shared object file: No such file or directory]
Mar 14 15:23:56 SERVERNAME sshd[13444]: PAM adding faulty module: /lib64/security/system-auth
Mar 14 15:24:31 SERVERNAME sshd[13444]: pam_winbind(sshd:auth): getting password (0x00000000)

Below is a fully functioning /etc/pam.d/sshd file that will work with RHEL 5.x (should also work with 6.x asumming no huge changes have been made to PAM)





#%PAM-1.0
account required pam_access.so
auth include system-auth
account required pam_nologin.so
account include system-auth
password include system-auth
session optional pam_keyinit.so force revoke
session include system-auth
session required pam_loginuid.so
 
  


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
[SOLVED] SSH: PAM Authentication Error rj3k Linux - Security 1 02-10-2011 09:30 PM
SSH + PAM + two-factor authentication tdnnash25 Linux - Security 21 06-18-2009 04:47 PM
PAM - only allow domain group members to log on via ssh? humbletech99 Linux - Networking 3 01-24-2006 11:53 AM
PAM authentication & NT domain rangel Linux - Security 2 11-27-2003 07:52 AM
PAM User Login Authentication Failure robeb Linux - Security 5 11-16-2002 08:01 PM

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

All times are GMT -5. The time now is 04:07 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