2

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

2 Answers 2

1

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.

1

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.

You must log in to answer this question.

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