ã»ãã¥ã¢ãª rsync - çå±ç·¨
ãµã¼ãé㧠rsync ã使ã£ããã¡ã¤ã«ã®åæã®èª²é¡ãä¸ããããå¾è¼©ãããããã調ã¹ã¦ãã©ãçãããµã¤ãã®å 容ãå¾ãããè¦ãè¾¼ãã æãæãããã¤ã±ã¦ãªããèªåãªããããªããã¨è¨ã£ã¦ãã¾ã£ããã¨ãããã¾ãããã»ãã¥ãªãã£ã«æ°ã使ã£ã¦ãssh çµç±ã§ rsyncãã¾ã§ã¯è¯ãã¨ãã¦ãsshd_config 㧠PermitRootLogin ã yes ã«ããã®ã¯ãå人çã«ã¯ãããããªããã¨æãã¾ããã
以åã«ãèªå㧠ssh + rsync ãå®éã«åãããæã«ãã©ããªé¢¨ã«èãã¦ãã©ã®ãããªäºããã£ãã®ããæ¸ãã¦ã¿ã¾ãã
åæã®æ¹å
rsync ã§åæããéããã¹ã¿ã¼å´ããããã·ã¥ããã®ããããã¯ã¢ããå´ãããã«ããã®ããã¨ãããããã¾ããåºæ¬çã«ã¯ã©ã£ã¡ã§ãè¯ãã¨æãã¾ãããä»®ã«ããã¯ã¢ããå´ããã¦ã³ãã¦ããå ´åã«ãä½åãªã¨ã©ã¼ãçºçãããããªããã¨æããããã¯ã¢ããå´ãããã«ããäºã«ãã¾ããã
éä¿¡æ¹æ³
ssh çµç±ã§ rsync ãããã¨ãéä¿¡å 容ãæå·åããããã¨ããã®ã¯æåãªææ³ã§ããã¤ã³ã¿ã¼ãããè¶ãã§ãªããã°ã第ï¼è ãéä¿¡å 容ãåå¾ãããã¨ã¯æ¡å¤ãé£ãã*1ã®ã§ãããæå·åãã¦ãããã¨ã«è¶ãããã¨ã¯ãªãã§ãã
èªè¨¼
rsync ãæåã§åããã®ã§ããã°ãæã§ãã¹ã¯ã¼ããå ¥åããã°è¯ãã®ã§ãããcron ã使ã£ã¦ã¹ã±ã¸ã¥ã¼ã«ã§åãããã¨ããã¨ãèªè¨¼æ å ±ãã©ããã«ä¿åããå¿ è¦ãåºã¦ãã¾ãã
ã¦ã¼ã¶åã¨ãã¹ã¯ã¼ãããã®ã¾ã¾ãã¡ã¤ã«ã¨ãã¦ä¿åããã®ã¯ãããã«ã¾ãããã¨æã人ã¯å¤ãã¨æãã¾ããããã®åé¿æ¹æ³ã¨ãã¦ãssh ã®å ¬ééµèªè¨¼ã§ç§å¯éµã®ãã¹ãã¬ã¼ãºãå¤ãã¦ä½¿ã£ã¦ãã人ããã¾ããããããä¸ã¤ã®æã ã¨æãã¾ãããã¡ãã£ã¨ããªããã¼ãªæãããã¾ãããã¹ã¯ã¼ããªã©ãå ¥åããªãæ¹æ³ã¨ãã¦ã¯ããã¹ããã¼ã¹èªè¨¼ã使ãæ¹ãä¸è¬çã§ãã
ãã¹ããã¼ã¹èªè¨¼ã§ãããã¹ãã¬ã¼ãºç¡ãã®ç§å¯éµã§ããåãå¼±ç¹ãããã¾ããããã¯ãç§å¯éµã裸ã®ç¶æ ã§ãã¡ã¤ã«ã«ä¿åãããç¹ã§ãããã®ãã¡ã¤ã«ãæµåºãã¦ãã¾ãã¨ããã¹ã¯ã¼ãèªè¨¼ã§ãã¹ã¯ã¼ãæååãæ¼ããã®ã¨å¤ããããã¾ãã*2ããªã®ã§ãç§å¯éµãæ¼æ´©ããªãäºã大åæã«ãªãã¾ãã
ãã®ä¸ã§ããã¹ããã¼ã¹èªè¨¼ã®æ¹ããã¿ã¼ãªç¹ã¯ããç¹å®ã®ãã¹ãã¨ç¹å®ã®ã¦ã¼ã¶ã«å¯¾ãã¦ã®ã¿ããã¹ãéµã使ã£ãèªè¨¼ã許å¯ãããã¨ãäºãã§ããç¹ã§ãã
ssh ãµã¼ããç¨æããå ´åãé常ã¯ãrsync ã®ã¿ã®ç¨éã§ã¯ãªããä¿å®ã»ç®¡çç¨ã«ãã°ã¤ã³ããããã«ã使ãã¾ããsshd ã§ç¹å®ã®ãã¹ãã許å¯ããå ´åãiptables ã®ãããªãã¡ã¤ã¢ã¼ã¦ã©ã¼ã«ãã/etc/hosts.allowã/etc/hosts.deny ã使ãäºã«ãªãã¾ãããã¨ããäºã¯ãrsync ã®åæ対象以å¤ã«ãä¿å®ç¨ã§ãã°ã¤ã³ãã¦ããå¯è½æ§ã®ãã端æ«ã許å¯ããå¿ è¦ãããã¾ãã
ãããããã¹ããã¼ã¹èªè¨¼ã§ããã°ããã¹ããã¼ã¹èªè¨¼ã§è¨±å¯ããããã¹ãã¨ã¦ã¼ã¶ã shosts.equiv ãã¡ã¤ã«ã使ã£ã¦çµãè¾¼ãäºãã§ããä¿å®ã»ç®¡çç¨ã®ç«¯æ«ã«å¯¾ãã許å¯ããªã·ã¼ããçãç¯å²ã§è¨±å¯ããäºãã§ãã¾ãã
ã¤ã¾ããæ¬å½ã« rsync ç¨ã«ã ãããã¹ããã¼ã¹èªè¨¼ãé©ç¨ã§ãã¾ãã
rsync ç¨ã®ã¦ã¼ã¶
ç¹å®ã®ã¦ã¼ã¶ã®ãã¡ã¤ã«ã ããåæããå ´åã«ã¯ããã®ã¦ã¼ã¶ã§ rsync ãåããã°è¯ããã¨ããäºã«ãªãã®ã§ãããä¸ç¹å®ã®ã¦ã¼ã¶ã®ãã¡ã¤ã«ã対象ã¨ããã®ã§ããã°ãä½ããã®å½¢ã§ root ç¹æ¨©ãå©ç¨ããå¿ è¦ãããã¾ãã
ããããsshd_config ã®ãPermitRootLoginãã Yes ã«ããäºã§åé¿ããã®ã¯ãã¡ã§ããããããã¹ã¯ã¼ãèªè¨¼ãæå¹ã§ããã¤ãå®æãªãã¹ã¯ã¼ããè¨å®ããã¦ãããããã«ã¼ããã©ã¼ã¹ã¢ã¿ãã¯ã§ root ãåããããã¨ã«ãªãã¾ã*3ã
ãªã®ã§ãrsync ç¨ã®ã¢ã«ã¦ã³ããç¨æããsudo ã使ã£ã¦ããrsync ç¨ã®ã¢ã«ã¦ã³ãã rsync ãå®è¡ããæã ã root 権éãä¸ãããã¨ãã¾ãã
ãªã¢ã¼ãå´ã® rsync ã¦ã¼ã¶
ãã¼ã«ã«å´ã¯ sudo ä»ã㧠rsync ãå¼ã³åºãã°ãroot 権éã使ãã¾ããããããããã§ã¯ãªã¢ã¼ãå´ã§å¯¾å¿ãã rsync ã¯ä¸è¬ã¦ã¼ã¶ã§åãã¾ãããªã¢ã¼ãå´ã§ rsync ç¨ã®ã¢ã«ã¦ã³ãã sudo ã®è¨å®ã§ root 権éãåããããã«ãªã£ã¦ãã¦ããroot 権éãåããã®ã¯ããã¾ã§ã sudo çµç±ã§ rsync ãå¼ã°ããæã§ãã
ããã§ãrsync ã®ããã¥ã¢ã«ããã£ã¨èªã¿ã¾ãã
ãã®ä¸ã«ã--rsync-pathãã¨ãããªãã·ã§ã³ã«ããã¾ãã
--rsync-path=PROGRAM
Use this to specify what program is to be run on the remote machine to start-up rsync. Often used when rsync is not in the default remote-shell's path (e.g. --rsync-path=/usr/local/bin/rsync).
ãã®ãªãã·ã§ã³ã§ããªã¢ã¼ãå´ã®ããã°ã©ã ãæå®åºæ¥ã¾ããä¾ã§ã¯ãããã©ã«ãã§è¦ã¤ãã rsync ã®ä»£ããã«ãã«ãã¹ãæå®ã㦠/usr/local/bin/rsync ãå¼ã³åºãããã«ãã¦ãã¾ãããããã使ã£ã¦ãsudo rsyncããå¼ã³åºãããããã«ããã°ããªã¢ã¼ãå´ã® rsync ã root ç¹æ¨©ã使ãã¾ãã
ã¾ã¨ã
ã¨ãããã¾ã§èãã¦ãããã¨ãã¾ã¨ãã¾ãã
- rsync 㯠ssh çµç±ã§ä½¿ãã
- ssh ã®èªè¨¼ã¯ãã¹ããã¼ã¹èªè¨¼ã使ãã
- rsync ãå®è¡ããããã®ã¢ã«ã¦ã³ããä½ãã
- rsync ç¨ã®ã¢ã«ã¦ã³ã㯠sudo ã使ã£ã¦ãroot 権é㧠rsync ãå®è¡åºæ¥ãããã«ããã
- rsync ã® --rsync-path ã使ã£ã¦ããªã¢ã¼ãå´ã® rsync ã sudo ä»ãã§èµ·åããããã«ããã
çå±ã¯ãããªã¨ããã§ãããé·ããªã£ãã®ã§å®è·µç·¨ã¯å¾æ¥ã«ãã¾ãã
*1:å½äºè ã¨ãªããã¹ãä¸ã§ã¯ç°¡åã§ãã第ï¼è ãååããã«ã¯ããããªãã«ä»æããå¿ è¦ã«ãªãã®ã§ãä¸å¯è½ã§ã¯ç¡ããã©ãããå¯è½ãªç¶æ ã«ãªã£ã¦ããã¨ãããããããããããªç©ãä¹ã£åããã¦ããç¶æ ã§ãã
*2:ããã§ããå ¬ééµèªè¨¼ã®æ¹ããã¿ã¼ãªã®ã¯ããã«ã¼ããã©ã¼ã¹ã¢ã¿ãã¯ã«å¯¾ããèæ§ããã¹ã¯ã¼ãèªè¨¼ãããé«ãç¹ã§ããã¾ãããã¹ã¦ã®ã¢ã«ã¦ã³ãã§ä¹±æ°ã§çæããä½ååãã®ãã¹ã¯ã¼ããè¨å®ããã°ããã¹ã¯ã¼ãèªè¨¼ã§ãèæ§ã¯é«ããªãã¾ããã
*3:PermitRootLogin ã No ãªã root ãåãããªã訳ã§ã¯ãªãã§ãããroot 以å¤ã®ã¦ã¼ã¶ã§ããã°ããããã root ãåãããã«ãã¾ãå¥ã®æ»æãä»æããå¿ è¦ãããã¾ããæè¦çã«ã¯ï¼ããã¯ã®æã¿ãããªæãã§ãã