I need to log into multiple servers at work to get my work done. I'm getting tired of typing the FQDN of a server to access. I'm logging in/out via ssh on our own private network. I'm 99% sure it's on our own private network b/c all the servers have ip addr 10.x.y.z. Is there a way to ssh into servers with just the hostname and not the domain name?
We have servers in multiple countries. The way our servers are named is very long. It is named as follows:
hostname.country.domainname.com
I am getting carpal tunnel typing in
ssh me@hostname1.country.domainname.com
… every time I access one of our servers. If I'm in the US and I try to access another host that's in the US, I can just type ssh me@hostname2
and I connect fine. However, if I'm in the US and try to connect to a server in England, I can't type ssh me@hostname3.eng
and connect to hostname3
.
The workaround I did was setup an alias in my ~/.ssh/config file for some of the servers. However, I don't think it's feasible to add 1000+ servers into that file. I've already added 20+ servers and my co-workers think I'm crazy, although I think they are crazy for typing the FQDN when sshing around.
Is there an easy way for us to set up something so that we don't have to type in our domainname.com each time?
Best Answer
You can wildcard and use
%h
in your configeg
Now when you do
ssh foo.eng
it will try to connect tofoo.eng.domainname.com
.You can add other options to this config as well; eg forcing the username
Now when you do
ssh foo.eng
it will try to connect tofoo.eng.domainname.com
as the userme
.(well, obviously I get an error before it's not a valid hostname for me!)
So now you only need one rule per country.