1

I'm writing a custom SSH server. Whenever I connect to it via ssh user@subdomain.example.com, I need to know the value of the subdomain.

Right now I can only get remote and local IP addresses.

Alex
  • 139
  • 10
  • If this is just you using the server, then you could export an environment variable that has the name you are connecting to and allow that on the server side. This is completely untrusted data and obviously can be spoofed, but that is one way I have seen it done (to set a prompt based on a cname). – Aaron May 13 '17 at 04:02

1 Answers1

5

The SSH protocol knows nothing about the hostname that's used to connect to it. The client merely resolves it to an IP address and then uses that IP to connect.

It sounds like perhaps you've had experience with HTTP servers, and their ability to be made aware of the hostname used to access them. This functionality is possible only because the HTTP client sets a Host header in the HTTP request, whose value is the hostname used to access the server. There is no equivalent functionality in SSH.

EEAA
  • 108,414
  • 18
  • 172
  • 242