LinuxQuestions.org
Visit Jeremy's Blog.
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 10-28-2019, 11:44 PM   #1
X1C
LQ Newbie
 
Registered: Oct 2019
Posts: 13

Rep: Reputation: Disabled
Best practice in implementing ssh-key based authentication


We implemented ssh-key based authentication. But what happens now is that when we add a new user, we need to edit the sshd_confif file, set PasswordAuthentication=yes which allows the new user to upload the new user's public keys to /home/userX/.ssh. Then I restart the ssh service. In our case, the users are in different locations, and we don't know when they will upload their keys. That means, we make our servers "vulnerable" during that time, with only the password to rely on.

After the new user uploads his/her keys, we then set PasswordAuthentication=no and restart ssh service.

Some existing users who did not upload their keys before the transition (from password based to key based authentication) also now want to upload their keys, which again means we need to "open" the server for them so that they too can upload their keys.

I am sure sysads have managed hundreds and hundreds of users, if not thousands, smoothly, but how do they do it without this kind of interruption? Is there anyway to automate this process? For example, could I do something like:
(1) use key based authentication for users who have already uploaded their keys
(2) If new users are added, or for the existing users who have accounts, but who have not uploaded keys, let them copy their keys with regular password (for example, using ssh-copy-id), so that we do not make our system vulnerable by "opening" it.

(3) No need to edit sshd_config file and restart the ssh service each time.

Or... is it unavoidable?
 
Old 10-29-2019, 12:27 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi

have the new user email the admin their public key and then the admin puts the public key in the users ~/.ssh/authorized_keys file.

Evo2.

P.S. Need to be careful to set the correct ownership and permissions of ~/.ssh/authorized_keys. A simple shell script makes it easy.

P.P.S. A weakness of this method is that if the users email is hijacked an attacker will be able to get control of their account on your system.

Last edited by evo2; 10-29-2019 at 12:32 AM. Reason: P.S.
 
Old 10-29-2019, 12:41 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Quote:
Originally Posted by X1C View Post
I am sure sysads have managed hundreds and hundreds of users, if not thousands, smoothly, but how do they do it without this kind of interruption?
Getting the public key from the user and adding it via a script, like mentioned above, is one option.

Another option with more steps but more flexibility would be to use SSH certificates. Those are basically signed keys. They are apparently widely used in large scale deployments but rather little is written about them so far, at least it's not easy to find, but there is still something:

One advantage is that you can put expiration dates on the keys.
 
1 members found this post helpful.
Old 10-29-2019, 05:38 AM   #4
X1C
LQ Newbie
 
Registered: Oct 2019
Posts: 13

Original Poster
Rep: Reputation: Disabled
evo2, Turbocapitalist

Ok. So some manual intervention can't be helped then...

T., I will read and see if we can use the ssh-certificates.

Thanks you two!
 
  


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
SSH skips public key authentication for a key, but works with another key simopal6 Linux - General 1 07-06-2011 08:33 AM
ssh best practice: key pairs per user or OS? Other considerations? mrtwice Linux - Security 2 04-20-2010 09:41 PM
clogin automated login with key-based ssh authentication m4rtin Programming 4 01-25-2010 12:06 PM
problem with ssh key-based authentication kaplan71 Linux - Security 5 12-09-2009 10:34 AM
Key based authentication only for root for SSH the_gripmaster Linux - Security 4 04-18-2009 05:43 PM

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

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