Friday, October 10, 2014

[メモ] root権限でrsyncする方法


そういった際には、sudo の -A オプションと rsync の --rsync-path オプションを使うと良いようです。

% cat > bin/askpass
#! /bin/sh
echo "{{my_password}}"
% chmod 700 bin/askpass
そして、rsync を実行する際には --rsync-path オプションを使い、リモートサーバの rsync を sudo -A 経由で起動するようにすれば良いのです。
% sudo rsync -avz -e ssh \
    --rsync-path='SUDO_ASKPASS=/home/remote-user/bin/askpass sudo -A rsync' \
    remote-user@remote-host:remote-dir local-dir


sudo -Aオプションはパスワードを記述したファイルを設置する必要があるという点でNOPASSWD同様セキュリティの懸念はありますが、使いどころを誤らなければ便利だなと思いました。


  1. This comment has been removed by the author.

  2. I just want to say thanks for your wonderful post, it is contain a lot of knowledge and information that i needed right now. Thanks!

  3. SysAppPro offers the best SAP PM Training in Gurgaon with the guide of the most skilled and very much experienced experts. Our educators are working in SAP PM and related advances for a significant number of years in driving global organizations around the globe. What makes us believed aces in this field is the way that we are obviously mindful of industry needs and we are putting forth training in a particularly viable manner.
    For More Info:- SAP PM Course in Gurgaon


Note: Only a member of this blog may post a comment.