Posted in Linux commands

ssh: bypass /etc/hosts and DNS

A common little problem in my daily work is to log on to another machine with a cryptic filename, e.g. First I have find out, that the web server is on that machine. How easy would it be to type just ssh webserver! The sysadmins don’t want to put this neither into the name service nor into /etc/hosts. But there is help.

I created a file config in the directory .ssh in the home directory. The content is (e.g.):

Host webserver

Now all I have to do is

ssh webserver

and ssh connects to

Another goodie: if you need another username on the remote machine you can include it in the config file:

Host webserver
    User applicuser

Now the command

ssh webserver

Connects to

Of course you have to provide (and remember) the password. This can be avoided with ssh keys (which will come in a later post).

BTW: scp uses this file, too. Helpful if you have copy files for patches to or log files from the remote machine(s).

One thought on “ssh: bypass /etc/hosts and DNS

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s