Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

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

Host my-machine

User me

HostName 192.168.63.1

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

share|improve this answer
    
Will this also work with ssh using tools such as scp and rsync? –  Mike Cooper Oct 1 '09 at 6:43
    
it will_______________ –  Kim Oct 1 '09 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
Password: 
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.

share|improve this answer
    
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 '09 at 21:52
    
.bash_aliases isn't always read by bash. To be sure, you might need to put it in ~/.bashrc –  Atmocreations Sep 30 '09 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.

share|improve this answer

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.

share|improve this answer
    
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 '09 at 22:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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