Skip to content

Instantly share code, notes, and snippets.

@bovender
Last active December 14, 2017 11:10
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 bovender/5bd181203aee2b747242f4566807bd1d to your computer and use it in GitHub Desktop.
Save bovender/5bd181203aee2b747242f4566807bd1d to your computer and use it in GitHub Desktop.
rsync with sudo on a remote Ubuntu machine
#!/bin/bash
# Uses rsync with sudo privileges on a remote machine
# By Daniel Kraus (bovender), released into the public domain
#
# Inspired by: https://unix.bris.ac.uk/2015/08/04/rsync-between-two-hosts-using-sudo-and-a-password-prompt/
#
# To use this, an askpass program must be installed on the
# remote node. For Debian/Ubuntu systems, use:
#
# sudo apt install ssh-askpass
#
# You may want to confirm the absolute path of ssh-askpass:
#
# which ssh-askpass
rsync -e 'ssh -X' --rsync-path='SUDO_ASKPASS=/usr/bin/ssh-askpass sudo rsync' "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment