All the computers I use run Ubuntu. To work from home, I SSH from my home computer to my lab computer as follows:
# First a port knock is needed
joe@homepc> telnet ssh.university.edu 9000
# Next SSH to one of the external SSH servers of university
# This logs me into one of many SSH servers serving as interface
joe@homepc> ssh [email protected]
# Finally SSH to my lab PC inside university network
student7@university999> ssh joedude@labpc
# And I am in my labpc
joedude@labpc>
How do I use rsync
to sync a directory on labpc
with a directory on my homepc
? Also, it would be awesome if there is some way to automate all of this so that I can rsync with just a single command from my homepc.
There are several ways to solve this, however, because we want to run the rsync command on your home PC, I think the best way would be to create a tunnel from your home PC to the labpc, as follows:
Now, on your home PC, you should be able to ssh directly into the lab PC:
Once this is working, then you can build up an rsync script.
I would add the following lines to ~/.ssh/config
Now, you should be able to do (in a separate window, after first two ssh logins are done):
There are lots more improvements you could make after this, but I would wait until you get the first part working, and then see how much automation you need. To completely automate this you would need to use ssh-keygen to allow ssh logins without a password. You could also add more to .ssh/config for the first outgoing ssh leg. Using the ProxyCommand parameter in .ssh/config you could automate the entire thing.