For FTPS, we rely on the DNS and public PKI to authenticate the FTP server when we first connect. On the first connection, foo.example.com resolves to 184.108.40.206 and my connection comes back encrypted by a private key that I can validate is truly owned by foo.example.com (more or less, given the issues with PKI).
But how does this work with SFTP (yes, I know it's SSH but I'm not terribly familiar with that)?
I know there are two common ways people use SFTP with regards to this question:
- Client is aware of the key to be used for connection in advance. This makes sense and is obvious to my question. I'm not asking about this.
- Client is unaware of the key to be used for the connection in advance. Instead they have a username and a password. This is the scenario where I'm specifically asking about.
For that second scenario, when I first connect to the SFTP server, how can I be sure it's truly my intended server and not some other server performing a MITM attack to then get my password (hopefully this is hashed & not easily stolen) and/or data?
I found this question but it doesn't seem to address the topic of server authentication, just client authentication.