I have VM's running in Azure, and I see this error quite frequently: The VMs can be reached using either fqdn or public ip. When ssh-ing to the fqdn I'm able to log in (part of the fqdn obfuscated deliberately): However, using the same VM's public ip I'm getting access denied:
I guess it's related to the suffix added after the user account, but how can I make sure this doesn't happen? I've also seen the same error when the VM has gotten a new ip address after having been shutdown for a period of time (basically locking me out of the vm). I'm generally running Ubuntu 14.04 vms if that's relevant.
When I look at the host keys, they are the same for the two connections, although I have to "approve" them separately to add both instances to known_hosts. I'm using putty on windows as my ssh client.
If the server has new ip address, putty will always prompt you approve the key. Putty can overwrite existing key if the ip address is different but in ssh (ubuntu terminal) usually it will reject it, you have to remove the old entry to make it working again.
As EEAA mention in the comment, ip address is the main "identification" for a server, so sometimes you can connect using ip but not using fqdn, it means dns resolve problem but if the other way around I can only think one problem here, firewall and/or port forwarding, you should check that