Is it possible to have a user specific hosts file, or some other way to map a ip address to a name on a Linux system. I want to be able to ssh to my local machine from an on campus lab without having to memorize my IP address.

I have a full unix account that I use from the lab, but not access to /etc/hosts. My home computer has a fairly static IP address, and it changes little enough I could update it by hand on the remote system.

Ideally I would be able to say ssh me@my_machine.

Edit: About OS, the OS of the host may vary, from Redhat to Ubuntu to even sometimes FreeBSD. I have multiple machines I use with the same account (yay giant University networks) and am just looking for a way to streamline connecting to specific machines.

I am also not interested in something like dynamic dns. By fairly static, I mean that last academic year, I saw my IP address change about 4 times over 9 months. myname.dyndns.org isn't a whole lot better than an IP address as far as typing (I am lazy :P). Maybe sometime I will use something like dyndns to watch for IP changes, but for now I not too worried.

  • None of the answers here have anything to do with a user-specific host file -____- Jun 5, 2015 at 17:31

4 Answers 4


Use a ~/.ssh/config file with something like

Host my-machine

User me


This way, you can even skip the "me@" and do just "ssh my-machine"

  • Will this also work with ssh using tools such as scp and rsync? Oct 1, 2009 at 6:43
  • it will_______________
    – Kim
    Oct 1, 2009 at 7:01

This is how I handle it...

In .bash_aliases

alias myhomepc='ssh me@111.222.333.444'
alias mydevpc='ssh me@mydevpc.work.com'

And then just use it like so:

myworkpc:~ $ myhomepc
Last login: Mon Sep 21 15:54:04 2009 from 111.222.333.445
myhomepc:~ $

Using a service like dyndns mentioned above is really handy as well.

  • I'd recommend this on top of the dynamic DNS method actually. This way you don't have to worry about your IP changing, plus you have a shorter command to type. alias myhomepc='ssh me@mybox.dyndns.org
    – John T
    Sep 30, 2009 at 21:52
  • .bash_aliases isn't always read by bash. To be sure, you might need to put it in ~/.bashrc Sep 30, 2009 at 22:01

What OS are you on specifically? Alternatively, if your router supports DDNS you can register with Dyndns.org and get a free domain name from them. The router will automatically update their record for your domain when the IP changes.


Consider DynDNS or No-IP. Even if your IP does change, the updater utility will let the DynDNS/No-IP server know your IP has changed and continue to forward to it accordingly. You can have an address like me@mybox.dyndns.org or me@unixbox.no-ip.org.

  • Or if you're using a router with third-party firmware, it can automatically update the DynDNS record each time the DHCP lease is renewed. For reference, I am using Tomato firmware on a Linksys WRT54G to do this.
    – EmmEff
    Sep 30, 2009 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.