OpenSSHã®ã»ãã·ã§ã³ãæããControlMasterã®ä½¿ãã«ããé¨åã¯ControlPersistã§è§£æ±ºã§ãã
OpenSSHã«ã¯1æ¬ã®ã³ãã¯ã·ã§ã³ã§è¤æ°ã®SSHã»ãã·ã§ã³ãæãã¦ä½¿ããæ©è½ãããã¾ããä¾ãã°ã~/.ssh/configã«
Host example.com ControlMaster auto ControlPath ~/.ssh/mux-%r@%h:%p
ã¨è¨å®ãã¦ããã¨ãæåã«æ¥ç¶ããsshã»ãã·ã§ã³ã®ã³ãã¯ã·ã§ã³(ãã¹ã¿ã¼ã³ãã¯ã·ã§ã³)ã使ãã¾ãããè¤æ°ã®SSHã»ãã·ã§ã³ããã¹ã¿ã¼ã³ãã¯ã·ã§ã³ã«æãããã¨ãã§ãã¾ã*1ã
主ãªã¡ãªããã¯ä»¥ä¸ã®ã¨ããã
- TCPã»ãã·ã§ã³ã¯1ã¤ãªã®ã§TCPã®åææ¥ç¶æ°ãå¶éããã¦ãããµã¼ãã§ãè¤æ°sshãå¯è½*2
- ã³ãã¯ã·ã§ã³ã使ãã¾ãããå ´åãæ¥ç¶ã«ãããæéãçã(sshçµç±ã§è¤æ°åã«åãã¦ã³ãã³ãæå ¥ã¨ãã§æéç縮)
- ã³ãã¯ã·ã§ã³ã使ãã¾ãããå ´åããã¹ã¯ã¼ãå ¥åããã¹ãã¬ã¼ãºå ¥åãä¸è¦*3
ã§ãããControlMasterã¨ControlPathã®è¨å®ã ãã ã¨å®ã¯ä½¿ãã«ãããã§ããã
ãã¹ã¿ã¼ã³ãã¯ã·ã§ã³ãåããã¨ãã§ããªã
ControlMasterã¨ControlPathã ãã®å ´åãæåã«æ¥ç¶ããSSHã»ãã·ã§ã³ã§ãµã¼ããããã°ã¢ã¦ããã¦ãã³ãã¯ã·ã§ã³ãæ®ã£ãã¾ã¾ã«ãªã£ã¦ãã¾ãã¾ãã
ctrl+cãªã©ã§å¼·å¶çã«åæããã¨ãæãã¦ããä»ã®SSHã»ãã·ã§ã³ãå
¨é¨è½ã¡ã¦ãã¾ããã§ããããã¼ãªããããã£ãã使ããã¼ã
ä¸å¿ctrl+zã§æ¢ãã¦bgã§ããã¯ã°ã©ã¦ã³ãåä½ããããã¨ãã§ãã¾ãããé¢åã ãééããã¨ãªã¸ã£ã³ãããã¯çãã
ããã§ã§ãããControlPersistè¨å®ã§ããã
ControlPersist yes
Host example.com ControlMaster auto ControlPath ~/.ssh/mux-%r@%h:%p ControlPersist yes
ã¨è¨å®ããå ´åããã¹ã¿ã¼ã³ãã¯ã·ã§ã³ãå¼µã£ãSSHã»ãã·ã§ã³ãçµäºããã¨èªåçã«ããã¯ã°ã©ã¦ã³ãã§åä½ãç¶ãã¦ããã¾ãã
ãã ãããã¹ã¦ã®SSHã»ãã·ã§ã³ãåæãã¦ããã¹ã¿ã¼ã³ãã¯ã·ã§ã³ã¯èªååæããã¾ããã
ããã»ã¹ãkillãããã-O exitã§æ示çã«åæ¢ãããã¾ã§ãã£ã¨ã³ãã¯ã·ã§ã³ãå¼µã£ãã¾ã¾ã«ãªã£ã¦ãã¾ãã¾ãã
ããã§ControlPersist (ã¿ã¤ã ã¢ã¦ãç§æ°)ã§ãã
ControlPersist (ã¿ã¤ã ã¢ã¦ãç§æ°)
Host example.com ControlMaster auto ControlPath ~/.ssh/mux-%r@%h:%p ControlPersist 10
ã¨è¨å®ããå ´åããã¹ã¦ã®SSHã»ãã·ã§ã³ãåæããã¦ãã10ç§éã«åæ¥ç¶ããªããã°ãã¹ã¿ã¼ã³ãã¯ã·ã§ã³ãèªååæããã¾ããããããããã俺ã®æ±ãã¦ãããã®ã ï¼
ãã ããControlPersistã使ããã®ã¯OpenSSH 5.6以é
ControlPersistã¯OpenSSH 5.6ã§å®è£ ãããæ©è½ãªã®ã§ãæå ã®sshã®ãã¼ã¸ã§ã³ã5.6ã§ããå¿ è¦ãããã¾ãããã¦ãããªãã®ç°å¢ã§ControlPersistã¯ä½¿ããã§ããããã
2012å¹´7æ7æ¥æç¹ã§ã®ControlPersist使ç¨å¯å¦
OS | OpenSSHã®ãã¼ã¸ã§ã³ | å¯å¦ | åè |
---|---|---|---|
Debian stable(squeeze) | 5.5p1 | x | testing(wheezy)ããå¯ |
Fedora 17 | 5.9p1 | o | 15ããå¯ |
FreeBSD 9.0 | 5.8p2 | o | |
Gentoo stable | 5.9p1 | o | 2010/10/11ããå¯ |
Mac OS X Lion | 5.6p1 | o | Lionããå¯ |
RHEL 6.3 | 5.3p1 | x | |
Ubuntu 12.04 | 5.9p1 | o | 11.10ããå¯ |
è¯ãã£ãã§ããï¼æèã®é«ãã¨ã³ã¸ãã¢ããããããªãæããOSXã¯Lionã§å¯¾å¿ãã¦ã¾ããï¼è¯ãã£ãã§ããï¼
使ããOSãæ¯è¼çæ°ãããã®ã§ãã対å¿ãã¦ãªãã®ã§ã注æãã ããã
ControlPersistã¯ã¯ã©ã¤ã¢ã³ãå´ã ãã®è©±ãªã®ã§ããµã¼ãå´ãControlPersistã«å¯¾å¿ãã¦ãªãã¦ã大ä¸å¤«ã§ãã
ã¾ã¨ã
ControlMasterã使ãã¡ãªããã¯SSHæ¥ç¶æéã®ç縮ã ã¨ç§ã¯æã£ã¦ã¾ããæ°ç§ç¨åº¦ã®æ¥ç¶å¦çãç縮ããã¦ä½ãå¬ãããã ã¨æãããããããã¾ãããã
- ä½åº¦ãsshæ¥ç¶ãçºçããSSHè¶ãã®CVS/SVN
- lsyncd(rsync)
- sshfs
- cactiã®sshã«ããã³ãã³ãåºåçµæåå¾
ãªã©ã§ãã®å¹æãååã«çºæ®ã§ããã¨æãã¾ããæ¯éä¸åº¦ä½é¨ãã¦ã¿ã¦ã¯ãããã§ããããã
ãªãã
Host * ControlMaster auto ControlPath ~/.ssh/mux-%r@%h:%p ControlPersist 10
ã¨ããã°ãã¹ã¦ã®SSHã«é©ç¨ã§ãã¾ãããX転éãagent転éå¨ãã«å¶ç´ããã*4ã®ã§ãåå¥ã«ãã¹ãåä½ã§æå®ããã®ãç¡é£ã§ãã