Background:
On my server there is a service running that listens on a domain socket at /srv/socket
for incoming connections and then interacts with the user that connected. Please note that this service is one that I wrote (in C++) so I can modify the service's behavior quite easily. Right now, no authentication or permission checking is done by this service (as you will see in a second this will have to change). A few developers (think five to ten) I am working with need access to this service (and this service only) from computers somewhere else in the internet. Because this service gives them quite a few privileges, I want the authentication to be as strong as possible, and the connection to be encrypted. The underlying question I have (to avoid any XY problem) is: How do I set this up?
Idea and Questions About It:
My original idea was to provide my own authentication and then use TLS for encryption (exposing the service on an external port of course). However, writing my own authentication is likely to lead to security flaws, and setting the connection up to work over TLS will be a pain.
My second idea was then to just use SSH. SSH already has very strong authentication and encryption, and basically does what I need it to. Unfortunately, I am not quite sure how to set this up. First, I of course do not want to give the devs full shell access, and so I will change their default shell to /bin/false
(as per a few other answers on this and related sites). But then I still need them to be able to connect to the relevant socket. I looked into ssh tunneling but that does not seem to be what I need, and other searches for things similar to "ssh as a proxy" all reveal related but not identical issues. What is the right thing to do here? Of course, I could write a custom executable that will act as a "shell" and simply connect those users to my service, but again, this code will be security sensitive and where possible I'd like to avoid writing my own.
Best Case Scenario:
Ideally, I'd like the following to happen:
- The user runs some command on their client.
- An encrypted connection to a proxy service on my server is created, and the user authenticates themselves to this service (ideally this is a well established service that is known to be reasonably secure).
- The proxy service opens a connection to my service, forwards the username (or some user identifier), and the connects the client.
What is the best way to go about doing this?