I have a ubuntu 16.04 @ linode.com.
I wanna be able to login through a subdomain (master.mydomainname.com) instead of an IP (192.0.2.1).
> hostname
domainname_master
> cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 ubuntu.members.linode.com ubuntu
192.0.2.1 master.mydomainname.com mydomainname_master
I have a working A & AAAA record subdomain at cloudflare, which reachable through a webbrowser (nginx)
but when I try
[email protected]
I cant connect: ssh: connect to host master.mydomainname.com port 22: No route to host
With the IP itself I have no troubles to connect via SSH.
Did I miss something?
I wouldn't recommend doing this in
/etc/hostsunless you have other reasons to do so. Instead, I'd recommend editing~/.ssh/config(or a new file in/etc/ssh/ssh_config.dfor all users) to add an entry to make this work for anything that uses SSH with your account (includingscp,sftp, andrsyncamong others).This content in your config file (learn more with
man ssh_config) will allow you to runssh masterorssh master.mydomainname.comorssh mydomainname_masterwithout needing to specify the host IP or even the username (root) on the command line. You always override the username by running e.g.ssh jan@master(If you're installing this system-wide, you probably don't want to specify the username.)