Complex Rsync TTY SSH and Sudo Action

October 13th, 2010

Faced with a hosting environment and security setup not entirely compatible to the software development and deployment workflows I'm used to, I looked to the awesome power of:

  • Rsync
  • SSH
  • Sudo

And the notes of "crashingdaily": rsync and sudo over ssh.

I chose option two, as I don't want to enable NOPASSWD in /etc/sudoers:

stty -echo; ssh sudo -v; stty echo
rsync -a -e "ssh" --rsync-path="sudo rsync" /archive

My solution is a bit different, whereas instead of sudo'ing to root, I'm sudo'ing to another user.

stty -echo; ssh cd / && sudo -v -u exampleuser; stty echo
rsync -a -e "ssh" --rsync-path="cd / $$ sudo  -u exampleuser rsync" /archive

I am very pleased with this solution as it uses standard tools that are or can be installed quite easily on most servers powered by open source software, is encrypted, and radically speeds up my automated workflow. SWEET!

Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022