I want to setup
rsync backups of my server, so I run the following command
rsync -r -e ssh --rsync-path="sudo rsync" [email protected]:/ /backup/
Ideally, that command would ask my private ssh key password, then connect, then ask the sudo password for rsyncuser, and then run rsync on the server. But I got the infamous error:
sudo: no tty present and no askpass program specified
So I had to add this to
sudo visudo), which basically gives passwordless full read-write access to the system to the user
rsyncuser, which is not to my taste:
rsyncuser ALL= NOPASSWD:/usr/bin/rsync
How can I instead tell sudo to read its password from, say, another TTY ?
That way, I could run
rsync in one terminal window on my local machine, and use another terminal window to open a (possibly separate) ssh connexion to the server, and supply the sudo password there.
The only way I think of doing something like that would be to use an
expect script around sudo, which reads the password from a named pipe, and I would write to that pipe from the other terminal.
Note: this is more for the sake of exeprimentation and learning than any practical purpose, I'm not trying to find out how to use sudo with rsync, I've already read all I could find about that.