Skip to content

Instantly share code, notes, and snippets.

@krisleech
Created June 21, 2019 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisleech/d9482cae07dd18215e8564c219a0fdd1 to your computer and use it in GitHub Desktop.
Save krisleech/d9482cae07dd18215e8564c219a0fdd1 to your computer and use it in GitHub Desktop.
rsync ssh

Using rsync from cron on server A to pull files from server B via ssh.

Server A has a passwordless private key, the public key is in authorized_keys on Server B.

I can ssh from Server A to Server B.

To prevent use of ForwardAgent specific no configuration file:

ssh -F /dev/null -v admin@servera

Once on the server try and ssh in to the server

ssh admin@serverb

"Permission denied (publickey)." as expected.

ssh -v -i /path/to/private_key admin@serverb

Now I am in the server. So the key works. Exit back out and try rsync.

rsync -P --archive --compress --quiet --rsh='ssh -v -i /path/to/private_key -o IdentitiesOnly=yes' admin@serverb:/src/path /dest/path

If it works then try without any ENV set (similar to cron):

env - rsync ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment