Do the SSH or FTP protocols tell the server to which domain I am trying to connect?
Solution 1:
The SSH/SFTP protocol does not have any mechanism to provide the host to the server.
There was a discussion about adding this functionality to OpenSSH, see "Virtual hosts" for ssh.
The FTP protocol does have HOST
command, which is an equivalent to the HTTP Host
header. It is specified by a relatively new RFC 7151. The RFC was published in March 2014 (though the first draft is from 2007). As such, it is not universally supported yet.
On a server-side, it's supported by IIS (the RFC is sponsored by Microsoft) and ProFTPD (since 1.3.6rc1). It's not supported by other common Unix FTP servers like Pure-FTPd or vsftpd.
On a client-side, it is supported by (my) WinSCP. It's not supported by FileZilla, as its author oppose the idea, nor by CyberDuck. I do not know about others.
Solution 2:
No, the SSH clients do not pass the DNS name you connected to on to the server.
As you said correctly, the name is resolved locally to the IP address.
It looks like I was wrong about FTP.
See the other answer for details.