Discussion:
pam/sshd question: allowing a user to try logging in more than once
Jeremy Brown
2004-11-09 22:04:21 UTC
Permalink
The subject line is fairly self-explanatory. Currently users who
connect to my debian testing machine at work are prompted for their
username, then their password only once. If a user enters a bad
password, he or she is kicked out immediately and must open a new ssh
connection in order to try again.

I would prefer it if a user were prompted for his or her password up to
3 times before the SSH connection terminates.

I don't completely understand the nuances of PAM, so I'm not sure if
this feature--asking for the password multiple times if incorrect--is
something that PAM handles or if it's something that OpenSSH handles
itself. Nevertheless, I've seen it done on other UNIX/Linux machines,
so I know it can be done.

Here's my libpam0g and openssh version information:

Package: libpam0g
Version: 0.76-22

Package: ssh
Version: 1:3.8.1p1-8.sarge.2

Any help would be greatly appreciated.

Thanks,

Jeremy Brown
***@brownjava.org
Jeremy Brown
2004-11-09 22:14:05 UTC
Permalink
Oops...I figure I should include my "common-auth" file too, as well as
mention that I authenticate against LDAP:

#
# /etc/pam.d/common-auth - authentication settings common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of the authentication modules that define
# the central authentication scheme for use on the system
# (e.g., /etc/shadow, LDAP, Kerberos, etc.). The default is to use the
# traditional Unix authentication mechanisms.
#
auth required pam_env.so
auth sufficient pam_ldap.so
auth sufficient pam_unix.so use_first_pass
auth required pam_deny.so

Jeremy
Post by Jeremy Brown
The subject line is fairly self-explanatory. Currently users who
connect to my debian testing machine at work are prompted for their
username, then their password only once. If a user enters a bad
password, he or she is kicked out immediately and must open a new ssh
connection in order to try again.
I would prefer it if a user were prompted for his or her password up
to 3 times before the SSH connection terminates.
I don't completely understand the nuances of PAM, so I'm not sure if
this feature--asking for the password multiple times if incorrect--is
something that PAM handles or if it's something that OpenSSH handles
itself. Nevertheless, I've seen it done on other UNIX/Linux machines,
so I know it can be done.
Package: libpam0g
Version: 0.76-22
Package: ssh
Version: 1:3.8.1p1-8.sarge.2
Any help would be greatly appreciated.
Thanks,
Jeremy Brown
Michael Sims
2004-11-09 22:19:38 UTC
Permalink
Post by Jeremy Brown
The subject line is fairly self-explanatory. Currently users who
connect to my debian testing machine at work are prompted for their
username, then their password only once. If a user enters a bad
password, he or she is kicked out immediately and must open a new ssh
connection in order to try again.
Hi,

Please see this archived message:

http://marc.theaimsgroup.com/?l=debian-user&m=109890625028036&w=2

HTH
Jeremy Brown
2004-11-10 05:04:19 UTC
Permalink
Post by Michael Sims
Post by Jeremy Brown
The subject line is fairly self-explanatory. Currently users who
connect to my debian testing machine at work are prompted for their
username, then their password only once. If a user enters a bad
password, he or she is kicked out immediately and must open a new ssh
connection in order to try again.
Hi,
http://marc.theaimsgroup.com/?l=debian-user&m=109890625028036&w=2
HTH
Check out my 2nd message. I'm authenticating against an LDAP server and
thus require PAM.

I know this can be done with PAM. I have a Fedora Core box that
authenticates against LDAP for OpenSSH (via PAM), and it requests my
password 3 times if invalid.

Jeremy
Michael Sims
2004-11-10 00:54:16 UTC
Permalink
Post by Jeremy Brown
Check out my 2nd message. I'm authenticating against an LDAP server
and thus require PAM.
Oops, sorry, I guess I didn't read carefully enough.
Post by Jeremy Brown
I know this can be done with PAM. I have a Fedora Core box that
authenticates against LDAP for OpenSSH (via PAM), and it requests my
password 3 times if invalid.
Are your users using PuTTY? For me, the problem only manifests itself with
PuTTY, connecting from every other SSH client I tried gave the expected
behavior (3 password requests).

Maybe someone on comp.security.ssh would have an answer?
Jeremy Brown
2004-11-10 13:45:18 UTC
Permalink
Post by Michael Sims
Are your users using PuTTY? For me, the problem only manifests itself with
PuTTY, connecting from every other SSH client I tried gave the expected
behavior (3 password requests).
Actually, that seems to be the case here as well. I mostly use PuTTY,
so I hadn't even tried to connect from another client. Maybe this is a
PuTTY bug, then?

Here's an oddity. When I use OpenSSH's command line client in Cygwin,
there's still a noticeable difference in output between talking to a
Debian server and a Fedora one:

Debian:

***@jeremy-bexv1nyb:~$ ssh ***@debianbox
Password:
Password:
Password:
Permission denied (publickey,keyboard-interactive).

Fedora:

***@jeremy-bexv1nyb:~$ ssh ***@fedorabox
***@fedorabox's password:
Permission denied, please try again.
***@fedorabox's password:
Permission denied, please try again.
***@fedorabox's password:
Permission denied (publickey,password,keyboard-interactive).


Perhaps getting PAM to spit out this extra data would be more, eh,
amiable to PuTTY? It is PAM that generates these "Password:" lines, right?
Post by Michael Sims
Maybe someone on comp.security.ssh would have an answer?
I can try. Is comp.security.ssh more general ssh questions, or mostly
OpenSSH-specific? If the former (and no one on debian-user has an
answer), I'm more inclined to move this to OpenSSH, PAM, or PuTTY
user/developer lists.

Thanks,

Jeremy
Jeremy Brown
2004-11-10 17:13:37 UTC
Permalink
Post by Jeremy Brown
Permission denied (publickey,keyboard-interactive).
Permission denied (publickey,password,keyboard-interactive).
Perhaps getting PAM to spit out this extra data would be more, eh,
amiable to PuTTY?
That's some good info. I noticed that if I set "PasswordAuthentication" to "yes",
Using username "michaels".
Access denied
Access denied
Access denied
Access denied
So, it actually prompts me 5 times. What's odd is that the first style of prompt,
simply "Password:", pauses after I hit enter...while the second one,
This may be good enough of a solution for you...it appears to be still using PAM,
although I'm not sure because my test box is still using /etc/passwd, and it prompts
more than once. It still bugs me that the output is different from my Red Hat
boxes.
I get the feeling that if either of us could spend a couple of solid hours reading
PAM and SSH docs we'd figure it out. To me, it hasn't been critical enough to
warrant that (yet). :)
OK. This is starting to make a little more sense.

I'm going to go ahead and bring debian-user back into the mix, for
feedback and progeny's sake (no pun intended).

Apparently OpenSSH has two authentication "modules", a "Password"
authentication module (which works with "/etc/passwd"), and a "PAM"
authentication module. You can set "PasswordAuthentication" and
"UsePAM" both to "yes", but if you do so you'll get two prompts (kind of
like what happens when you list two auth modules in a PAM file without
"use_first_pass"). One will be the PAM prompt:

Password:


and one will be the /etc/passwd authentication prompt:

***@gnu3.crye-leike.com's password:



This may work for you, if your box stores passwords in "/etc/passwd",
but it won't for me, because my box authenticates against an LDAP server
*and* /etc/password (for root and system-specific users). My LDAP
logins will work for the first prompt, but fail for the second.

Additionally, sshd has (at least) 3 ways it can obtain authentication
information from a client: publickey, password, and
keyboard-interactive. With "password" authentication, I believe the
client generates an appropriate prompt and passes the password back to
the sshd server. In the case of "keyboard-interactive", I believe the
server generates the prompt and communicates directly with the client
even before authentication has been completed (kind of like telnet). I
believe "password" here is distinctly different from
"PasswordAuthentication" in the sshd config file, which I think is
referring to using the file "/etc/passwd" as an authentication mechanism
itself (for systems that don't want or need PAM).

Now:

My PAM knowledge is a little hazy, but my rough understanding is that
one popular usage model for PAM authentication is as follows: an
authenticating application retrieves the username itself, then is
supposed to pass input/output file descriptors to PAM. PAM then uses
these to print the password string (in this case, "Password:") and read
the result. It then returns a success or failure code to the
authenticating application.

Apparently earlier versions of OpenSSH contained a
"PAMAuthenticationViaKbdInt" option which allowed you to specify whether
you would prefer PAM talk to the user itself or you would rather have
OpenSSH obtain the user's password directly (via "password"
authentication as opposed to "keyboard-interactive"), then send this
password to PAM. See this debian-security post for a better explanation
than I can give:

http://www.mail-archive.com/debian-***@lists.debian.org/msg06881.html

I tried putting this option in my "/etc/ssh/sshd_config" but got a "this
option has been deprecated" message when I tried to start up sshd. I
looked through the sshd_config man page but couldn't find any mention of
a new, equivalent option. Additionally, a Google search for "PAM
AuthenticationViaKbdInt" turned up mention of some security problems, so
I'm guessing that the OpenSSH team may have decided that it's just
better to let PAM modules "do the talking" (as it were) in all cases
where PAM authentication is necessary.

So, I think the Debian box is using keyboard-interactive to obtain
passwords (the model I described above), whereas the Fedora box is using
password to obtain them. This might also explain why when
authentication fails, the Debian box only returns:

Permission denied (publickey,keyboard-interactive)

while the Fedora box lists password authentication (not to be confused
with the "PasswordAuthentication" setting):

Permission denied (publickey,password,keyboard-interactive)


I got curious, so I physically walked up to both machines and logged in
at the console. Both machines gave me a "Password:" prompt (I think it
comes directly from PAM), which I believe confirms my suspicion: the
Fedora sshd is collecting your password, then passing it to PAM, whereas
the Debian sshd is letting PAM talk to the client directly.

This doesn't solve my immediate problem, which I am growing more
inclined to believe is a bug in PuTTY (a mishandling of
keyboard-interactive authentication). My only other guess is that on
authentication failure, PAM may be writing some control character that
PuTTY can't deal with.
Post by Jeremy Brown
Post by Michael Sims
Maybe someone on comp.security.ssh would have an answer?
I can try. Is comp.security.ssh more general ssh questions, or mostly
OpenSSH-specific? If the former (and no one on debian-user has an
answer), I'm more inclined to move this to OpenSSH, PAM, or PuTTY
user/developer lists.
Well, the reason I recommended that is because there is no PuTTY mailing list. From
<quote>
A.9.6 If putty-bugs isn't a general-subscription mailing list, what is?
There isn't one, that we know of.
If someone else wants to set up a mailing list or other forum for PuTTY users to
help each other with common problems, that would be fine with us, though the PuTTY
team would almost certainly not have the time to read it. It's probably better to
use the established newsgroup comp.security.ssh for this purpose
</quote>
If I understand correctly though, I could still report this as a bug via
putty-bugs; it's just that I won't be involved in any developer
discussion about the bug.

Thanks for the help. I think I will send this over to putty-bugs in a
few, and if I don't get any response there, I'll probably just stop
worrying about it and use the Cygwin port of OpenSSH more :)

Jeremy

Loading...