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.

I'm logged into a Linux box but I do not have root access to update the /etc/hosts file. I am connecting to a remote server via its IP address but I would like to connect via hostname instead.

Is it possible for me to configure something in my local session, so that every time I log in it will add my IP address to hostname mapping without being able to access /etc/hosts?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The hostname should resolve as it normally does, the only reason you might want to use the hosts file is if you want to change it to something shorter, like instead of ssh user@74.125.226.240 OR ssh user@google.com, you could change it to ssh user@goog by adding 74.125.226.240 goog in your hosts file.

What you could do is set up an alias for any of these connections if you're doing it through a terminal. for bash, it'd be in your .bashrc or .bash_profile in your home directory (~/.bashrc)

share|improve this answer
    
e.g. export fooserver = 192.168.1.100 in your shell's login script. Then ssh $fooserver or sftp $fooserver etc. –  RedGrittyBrick Nov 3 '11 at 15:51
    
I personally added things like this: alias sshandy='ssh user@{andy's server} -i ~/.ssh/andykey' and when I need to connect to andy's server, I just do sshandy –  Rob Nov 3 '11 at 16:35

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.