LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-26-2012, 01:51 AM   #1
vahab
Member
 
Registered: Jun 2011
Posts: 58

Rep: Reputation: Disabled
SSH public key authentication still works for locked user


Hi,

I have a RHEL 5.5 server.On this server there is an account named test for which I configured public key authentication and I am able to login from a remote server with this user without password.

The problem is when I lock this user with passwd -l or usermod -L ,I can still login from remote server. So it seems these commands only lock the shadow. Is there any way to prevent publickey authentication in this case.

Thanks.
 
Old 08-26-2012, 06:58 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Depends on how you manage user restrictions. If you set them in /etc/ssh/sshd_config you could use {Allow,Deny}{Users,Groups}. Else, if you don't like editing sshd_config each and every time, you could use a "pam_listfile.so onerr=fail item=user sense=deny file=/path/to/deny.file" in the SSH PAM stack and echo all denied user names into "/path/to/deny.file" one account per line.
 
Old 08-26-2012, 09:07 AM   #3
vahab
Member
 
Registered: Jun 2011
Posts: 58

Original Poster
Rep: Reputation: Disabled
I use neither of the restrictions you mentioned.
I am in charge of managing many servers with many users. When one user leaves the organisation I lock his/her user by usermod -L or passwd -l but seems it is not enough; because if he configured publickey authentication before he can still login to the server while his account is locked ,please correct me if I am wrong
 
Old 08-26-2012, 09:29 AM   #4
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: CentOS 7.4 with KDE
Posts: 262

Rep: Reputation: 22
Sure he can because test is using a separate login system, PKI. And test still has his public key. You need to rename or remove his private key(s) in /home/test/.ssh .

Be advised that it is never a good idea to make certs without a password. I know the point is to make passwordless logins, but don't give just anyone their public key. No one if possible, especially yourself as you are admin. :[

Just out of curiosity are you using ldap, or kerberos for normal auth? Are you making any use of selinux?

Last edited by Quantumstate; 08-26-2012 at 09:42 AM.
 
1 members found this post helpful.
Old 08-26-2012, 09:50 AM   #5
vahab
Member
 
Registered: Jun 2011
Posts: 58

Original Poster
Rep: Reputation: Disabled
We are using none of ldap,kerberos,selinux.

The point is users are able to edit their authorized_keys by themselves so after locking them they will be still able to login to the server. So I guess I will move or delete their .ssh directory in addition to locking their account after they left the company

Last edited by vahab; 08-26-2012 at 09:51 AM.
 
Old 08-26-2012, 12:49 PM   #6
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: CentOS 7.4 with KDE
Posts: 262

Rep: Reputation: 22
They won't even be able to get in (from their remote client with their public key) if you rename their private key (on the server), so they wouldn't be able to edit their keys.

PKI with no cert password is not a good idea anyway, except in special circumstances like an rsync backup server, or reverse SSH tunnels. Best to do these though with a special user with a login shell of /bin/false .

Interesting. You might want to consider Kerberos if you're managing a number of machines and accounts. It gives centralized control and coherency.
 
1 members found this post helpful.
Old 08-26-2012, 08:13 PM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
As far as managing passwords on keys, that's what "ssh agent" programs are for. You supply the unlocking password for the key once.

Macintosh OS/X is rather nice in that it will conveniently store these passwords in the OS/X "keychain" of your choice. You don't have to remember the random, unguessable string of gobbledygook that is the actual certificate encryption key.

Never use an ssh certificate that is not encrypted.
 
Old 08-27-2012, 12:00 AM   #8
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: CentOS 7.4 with KDE
Posts: 262

Rep: Reputation: 22
Well, for certain automated actions over the LAN you pretty much have to make passwordless certs. No alternative. But coupling that with /bin/false shell mitigates, as long as the client machine is secure.
 
Old 08-27-2012, 11:24 AM   #9
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
@vahab: I've got a checklist (that I put together years ago) for disabling users:

http://www.daemonforums.org/showthread.php?t=413

The home directory management step I outline there is another way to solve the issue you were experiencing.
 
1 members found this post helpful.
Old 02-19-2019, 03:25 PM   #10
hablutzel1
LQ Newbie
 
Registered: Jan 2009
Posts: 3

Rep: Reputation: 0
The following command will effectively deactivate one user (password and SSH key login):

Code:
$ sudo usermod --expiredate 1 <USERNAME>
From man passwd:

Code:
-l, --lock
    ...

    Note that this does not disable the account. The user may still be able to login using another authentication token (e.g. an SSH key).
    To disable the account, administrators should use usermod --expiredate 1 (this set the account's expire date to Jan 2, 1970).
 
  


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
Public key authentication works for root not for users sanjay87 Linux - Server 6 03-07-2012 11:49 PM
ssh public key authentication teacup Linux - Networking 4 11-27-2011 11:27 PM
SSH skips public key authentication for a key, but works with another key simopal6 Linux - General 1 07-06-2011 08:33 AM
Public Key Authentication with SSH edafe Ubuntu 1 08-26-2006 11:06 AM
Can't use public key authentication with SSH Noob69 Linux - General 5 01-06-2006 06:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

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