LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-24-2018, 03:56 PM   #1
MaverickApollo
Member
 
Registered: Oct 2003
Distribution: Debian
Posts: 57

Rep: Reputation: 15
Concern with ssh public keys


I've recently moved a server away from ssh passwords via PAM to certificate based authentication.

Uploading the id_rsa.pub files using ssh-copy-id, I thought what would stop anyone else knowing the username, create another certificate using ssh-key gen, uploading it to the server and gaining access?

Can anyone help me understand this potential risk?
 
Old 04-24-2018, 04:38 PM   #2
MaverickApollo
Member
 
Registered: Oct 2003
Distribution: Debian
Posts: 57

Original Poster
Rep: Reputation: 15
I guess I just wasnt seeing it correctly, as you have to actually get the key on the actual server, without Passwords enabled, there is no way to log in, until you actually install the certificate by manual process on the target.
 
Old 04-24-2018, 09:44 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
The SSH folks specifically talk about that concern here – https://www.ssh.com/ssh/keygen/#sec-...ires-Attention

Quote:

It is easy to create and configure new SSH keys. In the default configuration, OpenSSH allows any user to configure new keys. The keys are permanent access credentials that remain valid even after the user's account has been deleted.

In organizations with more than a few dozen users, SSH keys easily accumulate on servers and service accounts over the years. We have seen enterprises with several million keys granting access to their production servers. It only takes one leaked, stolen, or misconfigured key to gain access.

In any larger organization, use of SSH key management solutions is almost necessary. SSH keys should also be moved to root-owned locations with proper provisioning and termination processes. For more information, see how to manage SSH keys. A widely used SSH key management tool for OpenSSH is Universal SSH Key Manager.

Practically all cybersecurity regulatory frameworks require managing who can access what. SSH keys grant access, and fall under this requirement. This, organizations under compliance mandates are required to implement proper management processes for the keys. NIST IR 7966 is a good starting point.
Incidentally, this is one of the reasons why I use OpenVPN (with tls-auth) as the outermost bastion of my servers – restricting ssh and everything-else to users who have successfully passed that (cryptographically secured ...) gantlet. Unlike SSH, users can't manage their own certificates, and, also unlike SSH, credentials can be selectively revoked. If you can make it past the VPN, then you can see and use SSH, direct MySQL clients, and so-forth. Otherwise, you see absolutely nothing – no open ports, nothing that replies to you, nothing to attack or even try to attack. I discuss these ideas on my blog here.

Last edited by sundialsvcs; 04-24-2018 at 09:52 PM.
 
Old 04-25-2018, 03:36 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
The key can be placed by another account using a properly configured sudo or even root.

If you're worried about people changing their keys you can relocate them the AuthorizedKeysFile directive in sshd_config on the server. The default is ~/.ssh/authorized_keys. You can make another directory for the keys which all accounts can read and place each account's authorized_keys file there, readable by the account but not writable.

Code:
sudo mkdir -m 755 /etc/ssh/authorized_keys/

sudo touch /etc/ssh/authorized_keys/apollo
sudo chgrp apollo /etc/ssh/authorized_keys/apollo
sudo chmod 640 /etc/ssh/authorized_keys/apollo

sudo touch /etc/ssh/authorized_keys/maverick
sudo chgrp apollo /etc/ssh/authorized_keys/maverick
sudo chmod 640 /etc/ssh/authorized_keys/maverick

# etc
Then load the files with the apropriate keys.

In the SSH daemon's configuration:

Code:
AuthorizedKeysFile /etc/ssh/authorized_keys/%u
SSH Certificates might be similar but are signed and so resistent to modification.
 
  


Reply

Tags
certificate, passwordless, ssh



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
Multiple SSH Public Keys ssslackw CentOS 4 08-10-2016 08:22 PM
ssh public and private keys... sigint-ninja Linux - Newbie 5 05-07-2015 05:11 PM
how does SSH use public/private Keys tripialos Linux - General 5 01-15-2013 02:51 AM
SSH allow public keys only GATTACA Linux - Security 4 11-18-2006 02:34 PM
Help with SSH and public/private keys stodge Linux - Security 5 05-14-2003 01:22 PM

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

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