Local IP aliases (hostnames)

From Liki

(Redirected from Ssh and scp)
Jump to: navigation, search


/etc/hosts - How to alias IP's

Whenever you ssh or scp the syntax is usually:

> ssh myname@129.25.8.219

But remembering an IP address is hard if not impossible. There is a file in every Unix environment called "/etc/hosts" (the file is "hosts" in the root directory "/etc"). If the file has a line like:

129.25.8.219 newton

then the syntax for the ssh command is simply:

> ssh myname@newton

How to fake "/etc/hosts"

The file "/etc/hosts" is a system file and as such needs root to edit it. If you are not the computer administrator you need to create a local copy. The commands:

> cd ~
> mkdir etc
> emacs etc/hosts

Will open an editor to the local hosts file. Enter the lines as above:

129.25.8.219 newton

... save and exit emacs. Now to register the new hosts file:

> emacs ~/.bashrc

and add the following line:

> export HOSTFILE="~/etc/hosts"

Re-source your .bashrc file with

> source ~/.bashrc

and you should be able to use the alias power of the hosts file.

Regards, Jose Manchini Berita Unik Berita Hari Ini Berita Terkini my trans manfaat madu manfaat internet pengertian internet edit foto online manfaat minyak zaitun hari valentine 17 tahun video 17 tahun

Personal tools