Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What would I have to add to a SSH hosts entry in my config file so that everytime I ssh into that host, I get sent to specific initial path?

Host foobar
    User        foobar
share|improve this question
up vote 1 down vote accepted

While the existing answers are fine, not one person specifically mentioned that setting the home directory is done in the password file.

You can change the home directory by editing the /etc/passwd file (use vipw) or running the following command:

usermod -d /user/wants/this/path username

Utilities and methods differ between UNIXes, I'm assuming Linux. Modifying /etc/passwd directly will work for all of them.

share|improve this answer
+1 Of course, it is so obvious <Slaps forehead> I was assuming he was just a user on the server and not the administrator. – Richard Holloway Mar 9 '10 at 14:34
I specifically didn't mention this, because many programs write their config files into HOME, so either the directory gets cluttered with dotfiles or if the user doesn't have write access, many programs may give errors. – ptman Mar 9 '10 at 15:44
I specify system users home directories outside of /home all the time but they're not to be authenticated to. I didn't make any assumptions. Good point though, if the Jose actually intends to authenticate to this user, it would probably be better to do a rc hack with a cd. – Warner Mar 9 '10 at 15:56

That is not up to SSH. You will typically have your CWD set to HOME on login. May I suggest reading the man-page of your shell and putting a cd command in the initial login file?

share|improve this answer

I don't believe this is possible, but what you can do is add

cd /path/to/where/you/want

to the end of your .bashrc file (assuming you are running bash)

share|improve this answer

Your Answer


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.