« Return to Thread: Arriving at a specified directory instead of the user's home

Re: Arriving at a specified directory instead of the user's home

by Greg Wooledge :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View in Thread

On Sat, Mar 10, 2007 at 05:10:18AM -0800, agostonbejo wrote:
> By default when I ssh onto a machine, I arrive at the user's home directory.
> Can I somehow specify upon ssh'ing that I would like to arrive at a
> different one?
> Something like this:
>
> ssh -target-directory=~/local/mystuff user1@themachine
> password: ...
> user1@themachine:/local/mystuff # ...

ssh -t user1@themachine 'cd ~/local/mystuff && exec bash'

Keep in mind that since you are no longer running a login shell, you
may not have the full set of environment variables you expect (since
your /etc/profile and ~/.{bash_,}profile won't be sourced).  You can
change that by forcing a login shell in the exec part.

If you don't use bash as your shell, substitute appropriately.

 « Return to Thread: Arriving at a specified directory instead of the user's home