4

Trying to use an ssh key to a server which has different host names works with some host names, but not with others?

Is there some reason why ssh would work that way?

E.g. say hostname1.com and hostname2.com point to IP address 1.1.1.1.

using

  • ssh -i ~/.ssh/keyname user@hostname1.com works,
  • ssh -i ~/.ssh/keyname user@hostname2.com doesn't.
  • ssh -i ~/.ssh/keyname 1.1.1.1 works.

Another interesting point is when I try to use ssh-copy-id to send the public key again via hostname2.com, ssh-copy-id is able to login and discover that the public key is already present in the authorized_keys file without my having to provide the password for the connection which means that there is a difference between ssh and ssh-copy-id which causes ssh to prompt for the password.

closed as unclear what you're asking by Gilles, Anthon, slm Apr 10 '16 at 22:23

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Have you tried hostname2 before it was properly created, and not cleaned your DNS caches? What happens if you instead use hostname2.com. ? How does the output of dig ANY hostname1.com and 2 differ? – Rui F Ribeiro Apr 10 '16 at 7:44
  • You must have error messages when things don't work, can you add those to you question? – Law29 Apr 10 '16 at 7:53
  • As above noted, make sure that the resolved IP in the verbose log (ssh -vvv hostname1.com is really the same as the one for hostname2.com. Secondly, check the verbose log, what is actually going on with the key. The last thing is error log (possibly in DEBUG3 loglevel), which should tell you why the key was accepted or rejected. – Jakuje Apr 10 '16 at 8:01
  • What are your known host settings on client and server? – Nils Apr 10 '16 at 12:53
  • Do you have rules in ~/.ssh/config that apply to one of the hosts but not the other? As requested, please post the full transcript of ssh -vvv … for both hosts (with consistent anonymization). – Gilles Apr 10 '16 at 20:42

Browse other questions tagged or ask your own question.