How do I switch on PAM debugging in Debian Squeeze at the admin level?
I have checked every resource I was able to find. Google, manpages, whatever. The only thing I haven't tried yet (I simply not dare to, did I mention that I hate PAM?) is digging into the PAM's library source.
I tried to google for a solution, nothing. What I found so far:
http://www.bitbull.ch/wiki/index.php/Pam_debugging_funktion (/etc/pam_debug
) and
http://nixdoc.net/man-pages/HP-UX/man4/pam.conf.4.html (debug
option on PAM entries in /etc/pam.d/
).
Nope, does not work. No PAM output, nothing, absolute silence.
While searching for a solution I even followed links to Pam, that are gas stations here in Germany. Well, yes, perhaps in all those billion of hits might hiding a clue, but shoot me I'd be dead before I discover.
Rest is FYI:
What problem did I have?
After upgrading to Debian Squeeze something got weird (well, hey, it once was, uh, what was right over the Etch .. ah, yes, Woody). So it's probably not Debian's fault, just a long lived screwed up setup. I immediately had the impression it has to do something with PAM, but I really did not know what's going on. I was completely in the dark, left alone, helpless as a baby, YKWIM. Some ssh logins worked, some not. It was kind of funny. No clues in ssh -v
, no clues in /var/log/*
, nothing. Just "auth succeeded" or "auth fail", sometimes the same user logging in parallely succeeded with one session and failed with the other, at the same time. And nothing you really can get hold of.
After digging trainloads of other options I was able to find out. There is nullok
and nullok_secure
, a Debian special. Something screwed with /etc/securetty
and depending on the tty
(which is somewhat random) a login was rejected or not. REALLY NICE, phew!
The fix was easy and everything's now fine again.
However this left me with the question, how to debug such a mess in future. It's not the first time PAM drives me nuts. So I would like to see a final solution. Final as in "solved", not final as in "armageddon". Thanks.
Ah, BTW, this again strengthened my belief in that it's good to hate PAM since it came up. Did I mention that I do?
A couple of things for you to try:
Did you enable logging of debug messages in syslog?
Add the following line:
Exit with
:wq!
.You can enable debugging for all modules like so:
OR you can enable debugging only for the modules you're interested in by adding "debug" to the end of the relevant lines in
/etc/pam.d/system-auth
or the other/etc/pam.d/*
files:Then debugging messages should start appearing in
/var/log/debug.log
. Hope this helps you out!At least on CentOS 6.4,
/etc/pam_debug
is NOT used.If the pam_warn.so module is installed, you can get some logging output this way:
etc. This module ensures that it will not interfere with the authentication process at any point, but it logs meaningful stuff via syslog.
Update
After examining the code and doing some compiling, I found that (1) it's possible to enable this debug mode through the source, and (2) a RHEL patch makes the feature nearly unusable (at least the pam_unix module) and (3) it's probably better to patch the code anyway.
To get this to work for RHEL, you can get the Linux-PAM ... src.rpm (for any 1.1 version) and change the spec file as follows:
Find the line beginning with
%configure \
and after it, add --enable-debug \
Then build the rpm and install (with force, to overwrite existing packages). Now create the file /var/run/pam-debug.log:
If the file does not exist, debug output will be sent to stderr.
This sending out to stderr is, in my opinion, stupid, and is what causes the patch conflict. You can change that behavior by going into the file libpam/include/security/_pam_macros.h and replacing the 4 lines of
logfile = stderr;
with
On build, you'll get warnings about unreachable statements, but they can be ignored. You can make this change in a sed script (and put it in the %prep section of the RPM after the patches)...
IF you do this little patch, you can restore the %patch2, as it should work again properly.
Debian and Ubuntu (and maybe other distros) have a special log file into which all pam output is logged:
/var/log/auth.log
I've been struggling with a pam related problem for a day and a half, finally found out about this log file, and saved myself from insanity.
Here's a sample of the contents of this file when things don't go as planned.
Here's how it looks when it works:
Note that none of the other possibilities for enabling pam debug logging worked for me.
I just happened to spend several hours trying to find out how to enable debug logs in PAM on CentOS 6.4. Although this question is for Debian, I will still write down how to do it on CentOS in the hope that other people don't have to put in the time that I already have.
As it ultimately turned out, enabling debug logs in the
pam
CentOS package is straightforward. The difficulty stems from the fact that it involves recompilation of the package. So, first find the SRPM (e.g.pam-1.1.1-13.el6.src.rpm
) from here. Folks who don't know about compiling packages from SRPMs, can refer to the steps on setting up a RPM build environment.Here is the main step. Open the spec file and add
--enable-debug
to the%build
section in theconfigure
invocation. Recompile! Reinstall the newly created package. Finally, create the file where debug logs will get written.If you don't create the file then a lot logs will fly by at the terminal, which might not be very useful.
Asket... I really loved your post :) I was fighting with stuff like this for the last 15 hours... (I might have had a 30 min break though)
Somehow i got it working by doing all the stuff you did, which means i have a /etc/pam_debug and debug on pam entries. BUT as in my case i was struggling with
pam_mysql
, I had to put anotherverbose=1
afterdebug
on my pam entries:That "sqllog" is just to write logs in the DB.
So maybe this helps you just a little bit.
We all hate PAM. Good luck!
Could you expand on that a little?
Per securetty's manpage:
The behaviour you describe sounds quite a lot like securetty is working normally (assuming you are indeed logging on as root).
Here too, there may be non-PAM restrictions in place, so it may help to provide some insight into what your
/etc/ssh/sshd_config
looks like.Notably, from your description:
sshd_config
:PermitRootLogin no
sshd_config
ofAllowGroups
orAllowUsers
. A sample line might look like:AllowGroups users admins
It is of course entirely possible PAM is part of the issue, but your main 'symptoms' sound to me like they could be explained by other means.
Basically this information is present in other answers, but mostly hidden in lines of text.
One option is to pass
debug
to a module, that makes it more verbose but not much.If you need more information, you need to build
pam
with--enable-debug
. Either by building from source (autoreconf && ./configure --enable-debug ... && make install
), or from a source package (deb, rpm, ...), which is OS-specific. As a result, if it has enough permissions, it creates/var/run/pam-debug.log
and writes to it. Otherwise, it outputs to stderr. You might want to create/var/log/pam-debug.log
in advance for it to have enough rights.About
/etc/pam_debug
, it didn't work for me.