Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I use the following config in my ssh config file:

Host host1
  Hostname host1
  User root 
  ForwardAgent yes 
  Port 22 
  ProxyCommand ssh -q user@host2 nc %h %p 

Is there a way to jump to a specific path when I connect using ssh host1?

I need this for shortening my rsync commands. For example instead of typing:

rsync dir1 host1:/var/www/dir0/dir1/

I want to type:

rsync dir1 host1

share|improve this question

As you seem to have root access to the remote box, you can add another user with the appropriate rights and a home directory at exactly that place.

This way you can leave out the path, because it's the home directory and you don't have to work as root.

share|improve this answer

This can't be done to my knowledge in the ssh config file. However, if you ssh into host1 and edit root's .bashrc file, you can accomplish the same thing.

[root@host1] $ echo "cd /var/www/dir0/dir1/" >> ~root/.bashrc

Then exit and ssh back in to verify it works for you.

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.