I have a Linux server with a single, static IPv4 address and several DNS entries pointing to the IP. The server hosts several Docker container, and listens on port 22 for incoming SSH connections.
There are three different use cases, where SSH connections to the server are made:
- access to git repositories (git.myserver.tld, username is always git, access is realized by using different keys)
- access to files using sftp (data.myserver.tld, username is always data, access is realized by using different keys)
- direct access to the server (myserver.tld, username corresponds to local unix user)
The first two servers (git and data) are each running inside a Docker container. My question is: Is it somehow possible to redirect incoming SSH connections to the SSH servers of the Docker containers, if Git or Data is required, or handle it directly if not? Could this be realized by looking at the username (redirect if it is git or data, handle it otherwise) or the hostname (is there some equivalent to SNI for TLS)?
Using another port than 22 is not an option, as the access should be allowed from environments, where only a few ports are allowed for outgoing connections.
The user management is handled by the appropriate Docker container services; there is no static list of SSH keys used to connect, but no connection ever uses password authentication.
The server runs Debian Linux with OpenSSH.
[Edit]
I do not think that this is a duplicate, because my questions was not only about the possibility to define hostname-based virtual SSH servers. I also asked if it is possible to differ on a per-user basis, which is not handled by the linked question. The username is transmitted during the SSH session, so there might be a possibility..