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. machine007.domain.com. 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
    Hostname machine007.domain.com

Now all I have to do is

ssh webserver

and ssh connects to machine007.domain.com.

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

Host webserver
    Hostname machine007.domain.com
    User applicuser

Now the command

ssh webserver

Connects to applicuser@machine007.domain.com.

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).

Advertisements

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

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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