[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


ssh key-exchange - how can the server verify the client?

Posted on 2015-02-23
Medium Priority
Last Modified: 2015-03-04
I thought I understood how ssh key exchange works; Once a connection is established, the server encrypts messages with the clients public key so only the client can decrypt it.

But what if more that one client has a copy of that private key? Either by design, or if a client system is cloned (or even just renamed), the copy of the key works - so a client cloned for a test  environment still has a key to the production server. The "tag" in id_rsa.pub, e.g. "root@myPC" doesn't necessarily relate to "myPC"

A client system checks the fingerprint of the server and will complain if it changes (ssh_config - StrictHostKeyChecking - unless that has been disabled); But can it be set up the other way around, so a key is only usable by a fingerprinted client?
Question by:tfewster

Assisted Solution

by:Oleksiy Gayda
Oleksiy Gayda earned 300 total points
ID: 40626244
The short answer is - there should never exist more than one copy of your private key. The whole point of the public key cryptography is to assure authenticity and non-repudiability of communications, based on the fact that a specific private key is unique to a specific client. Easiest way (and, arguably, the only correct way) to fix the predicament you're describing (multiple copies of the private key existing) is to revoke and replace the compromised key. Other than that, your only chance at differentiating systems would be by a public IP address (which wouldn't help if both systems are connecting from the same NAT-ed/public IP address).
LVL 33

Expert Comment

by:Dave Howe
ID: 40626252
not quite how it works.  the public key of the server is used to authenticate to the client & also protect the setup of a symmetric key used to encrypt the rest of the conversation.  over that encrypted channel,  the client authenticates using a supported method - password,  pki, kerberos token,  whatever; if that is compromised,  then the server won't know different than from the genuine user, but that is true of all systems.
LVL 33

Expert Comment

by:Dave Howe
ID: 40626257
in the case where multiple users log into the system as the same account (but with different keys),  often it won't even log which key was used. :(
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 21

Assisted Solution

Mazdajai earned 150 total points
ID: 40626824
Be design. Any client with private key can have access to any servers with the correct pair of public key with no passphrase.

You can setup passphrase in the event that private key is lost and only access to the client with the correct passphrase.
LVL 21

Accepted Solution

tfewster earned 0 total points
ID: 40627715
Thanks to all for your comments and insights. To be fair, I didn't set up this environment so the copies of keys lying around aren't my  doing, but I need to clean it up and only allow key-pair "trust" relationships where they are truly appropriate.

I think my answer lies in `man sshd`: The section on the authorized_keys file describes the "from" option that can be put in that file on the server, e.g
from="tfewsters_PC.example.net" ssh-rsa  AAAAB2...19Q== just_a_tag@example.net

Open in new window

would only allow that key to be used from client "tfewsters_PC.example.net".  Wildcards and IP addresses could be used, so I could specify 'from="192.168.1.*"'  to say 'If that have the key AND they're on the (e.g. production) subnet, they're trustworthy'.

I did think about iptables, or internal firewalls, but this seems quite simple to administer and I can manage the distribution of the authorized_keys file to a group of servers
LVL 33

Assisted Solution

by:Dave Howe
Dave Howe earned 150 total points
ID: 40627852
Yes. that can help a lot - if a given key is associated with a given source ip range, then limiting logins to that range can help prevent abuse. Of course, if you don't need ssh from outside your own IP range, you can lock that down completely using iptables then you won't get half of chinanet knocking on the door.... :)
LVL 21

Author Closing Comment

ID: 40644173
Found the solution myself. None of the Expert comments helped toward that, though they confirmed my views so partial points have been awarded.

To clarify my example scenario, I'm not really talking about PCs and end-user clients: If you have a client-server application environment or a server cluster, you may want trust relationships between the servers so e.g. a Cluster master can distribute config files to its peers/subordinates.  If the Production systems are cloned to set up a Test environment, the keys _should_ be revoked - but that step may be missed.

Featured Post

Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as the high-speed power of the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us in IT utilize a combination of roaming profiles and folder redirection to ensure user information carries over from one workstation to another; in my environment, it was to enable virtualization without needing a separate desktop for each…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month19 days, 8 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question