1

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
    HostName    foobar.com
    User        foobar

3 Answers 3

1

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.

3
  • +1 Of course, it is so obvious <Slaps forehead> I was assuming he was just a user on the server and not the administrator. Mar 9, 2010 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, 2010 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, 2010 at 15:56
0

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?

0

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)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .