Is there a user specific equivalent to /etc/hosts?

Solution 1:

For anything ssh based (including rsync over ssh) you can add entries to your ~/.ssh/config file

e.g.

Host myhost
    Hostname myhost.example.com

Then ssh myhost will connect you to myhost.example.com

Solution 2:

Specific applications may have something you can use, like Nick suggested, but there is no user homedir equivelent of the /etc/hosts file.

When applications try to resolve hostnames it gets handled by NSS. You can check how NSS handles hostnames on your system by looking at /etc/nsswitch.conf

$ grep host /etc/nsswitch.conf 
hosts:          files dns

This means that hostnames will be resolved first against the file database (/etc/hosts), and failing that against the dns details specified in /etc/resolv.conf

Solution 3:

I was wondering the same thing and a colleague found this solution: http://blog.tremily.us/posts/HOSTALIASES/

It basically involves setting an environment variable (HOSTALIASES) which points to the file to use for host aliases (you could use ~/.hosts for example).