Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

When I ssh into my freebsd I want to be automatically in another directory, and not my home directory.

I.e. instead of /users/home/john I want to be in /users/home/john/what/i/am/working/on

share|improve this question

ssh -t jdoe@example.com 'cd /tmp && exec /bin/sh'
share|improve this answer

So the simplest case of this is pretty easy. In your ~jdoe/.profile you can add:

if [ X$SSH_TTY != X ]; then
   cd /users/home/john/what/i/am/working/on
fi

If you're looking for the system to remember which directory you're in, per-terminal, and go back to the right one when you log back in on that terminal, that's more complex but still do-able with shell. Since $SSH_TTY is a filename, you can prepend "~/.mydirs/" to it, and use that filename to hold a copy of the CWD for the session of that terminal. It's more complex than that, but this is the general idea.

Hope this helps!
-pbr

share|improve this answer
ssh john@someplace:/path/to/wherever

notice the colon               ^

share|improve this answer
    
with which version of ssh is that possible? i always get 'could not resolve hostname xyz:/path ... and i dont see anything close to your suggestion in 'man ssh'. did you mix that up with 'scp'? – akira Sep 13 '09 at 9:24

You must log in to answer this question.

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