Q:

SSH protocol determine hostname used by client

I am attempting to create an SSH server (using Paramiko, but that's mostly irrelevant here).  I am wondering if there is any way to determine the hostname that the SSH client requested.  For example, if I were to connect with
ssh user@example.com

but I also had a CNAME record that pointed to the same server so I could also connect with
ssh user@foo.com

then I would like the server to know in the first case the user requested example.com and in the second, foo.com. 
I have been reading through SSH protocol documents like:
https://tools.ietf.org/html/rfc4253
https://tools.ietf.org/html/rfc4252
But cannot find out if there is a way to do this.  

A:

In general, the ssh protocol does not support this.   It's possible that a given ssh client may send an environment variable that gives you a hint, but that would happen after key exchange and user authentication, which would be far later than you'd want the information.   It happens that if you were using Kerberos authentication via one of the ssh GSS-API mechanisms  described in RFC 4462, you would get the hostname the user requested as part of the GSS exchange.   That almost certainly doesn't help you, but it happens to be the only case I'm aware of where this information is sent. 
For ssh virtual hosting you're going to need to dedicate an IP address or port for each virtual host.   Take a look at port sharing or IPv6 as possibilities for your application.