How to run rsync on remote host with sudo?

How to run rsync on remote host with sudo?

The naive solution would be to try to inject sudo into the remote command that rsync wants to run: However, as you can see that will not work as sudo wants to prompt for your password. The ssh connection is non-interactive and does not have any pseudo-tty allocated.

How to pass password to SSH server using rsync?

Run rsync over SSH using password authentication, passing the password on the command line: $ rsync –rsh=”sshpass -p myPassword ssh -l username” server.example.com:/var/www/html/ /backup/ OR $ SSHPASS=’yourPasswordHere’ rsync –rsh=”sshpass -e ssh -l username” server.example.com:/var/www/html/ /backup/.

Can a remote Sudo ask for your password?

You can have the remote sudo ask you for your password through X-windows. Here’s a way to do that: If there is no access to sudoers file, just create a wrapper script for the ssh command.

Can you run rsync as root without a password?

Well, simple. With the recommended configuration, rsyncuser may now run rsync as root without even being asked for a password. rsync is a very powerful tool to manipulate files, so now rsyncuser has a very powerful tool to manipulate files with root permissions.

Can you use rsync on the destination machine?

The user on the destination machine is able to use sudo. Is it possible to use rsync with sudo? Edit the /etc/sudoers file: sudo visudo (see also: must I use visudo?) Add the line ALL=NOPASSWD: , where username is the login name of the user that rsync will use to log on.

How to stop Sudo from prompting on TTY?

In order to stop sudo from prompting on the tty (which basically is the same as standard input over ssh), sudo can be told to launch another program instead. This program will obtain the password from the user and pass it on to sudo. One example for such a program would be ssh-askpass, which presents a X11 window prompting for the password.