SSH wont log into VPS using DNS

I'm working on a Virtual Machine where I have Ubuntu Server, in that server I connect to my cloud server (ubuntu), via ssh , but when I tried to log in with this syntax:

ssh subdomain.example.com 

It brings this error :

Permission denied (publickey)

But If I use any of this syntax :

ssh [email protected]
ssh my_user@cloud_IP

I login without a problem. So I was just wondering If the first syntax is wrong or I have something messed up within sshd_config file or my cloud server firewall service configuration. I've used ssh -vvv subdomain.example.com to debug it and this is what It shows: image


Your user name on the client machine is used as default for ssh connection to remote machines. You say it works when you do:

ssh [email protected]

but not when you do:

ssh subdomain.mydomain.com

Therefore we must assume that your user name locally is not user.

If that is the case you can either specify user every time or you can add an entry to your $HOME/.ssh/config file that says "my user name at subdomain.mydomain.com is user":

Host subdomain.mydomain.com
    User user

DNS does not come in to it because both of your examples are connecting to the same host. If this is not the case and you have made a copy/paste/redaction error, please update the question and consider not redacting the real host names involved as it makes it harder to help you.