commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
While `sshfs $REMOTE_HOST:$REMOTE_PATH $LOCAL_PATH` "pulls" a directory from the remote server to the local host, the above command does the reverse and "pushes" a directory from the local host to the remote server.
This makes use of the "slave" option of sshfs which instructs it to communicate over plain stdin/stdout and the `dpipe` tool from vde2 to connect the sftp-server stdout to the sshfs stdin and vice-versa.
rsync by itself doesn't support copying between two remote hosts, but if you use sshfs you can pretend one of them is local. If you have a passphrase-less ssh-key, you can even put this script into a cron job.
A faster alternative is to run ssh-keygen on remote1 and put the pubkey into remote2:~/.ssh/authorized_keys, running rsync on remote1 (or vice versa), but the problem with that is that now a hacker on remote1 can access remote2 at any time. The above method ensures your local computer stays the weak link.
Mac install ssh-copy-id
From there on out, you would upload keys to a server like this:
(make sure to double quote the full path to your key)
ssh-copy-id -i "/PATH/TO/YOUR/PRIVATE/KEY" [email protected]
or, if your SSH server uses a different port (often, they will require that the port be '2222' or some other nonsense:
(note the double quotes on *both* the "/path/to/key" and "[email protected] -pXXXX"):
ssh-copy-id -i "/PATH/TO/YOUR/PRIVATE/KEY" "[email protected] -pXXXX"
...where XXXX is the ssh port on that server
you can use this command for mounting local directory to a remost directory..