.ssh/configã®æ¸ãæ¹
sshã使ã£ã¦ãã¨æ¥ç¶ãããµã¼ãæ¯ã«ããã¼ããéã£ããç§å¯éµãéã£ããã§å¼æ°ãåãæ¿ãããã¨ãããããã
æ¥ç¶ãããµã¼ãæ¯ã«æå®ããå¼æ°ã¯æ±ºã¾ã£ã¦ããã®ã§ãããã·ã§ã«ã¹ã¯ãªãããã¨ã¤ãªã¢ã¹ã§å¯¾å¦ãã¦ãããã.ssh/configãç¨æããã°sshå´ã§é¢åã¿ã¦ãããããã ã(scpãsftpã§ãå¯)
ã¾ãã«ç¯å°ãã¨æããããã使ããªãæã¯ãªããã
Hostã»ã¯ã·ã§ã³
.ssh/configã¯ãæ¥ç¶å ã表ãè¤æ°ã®Hostã»ã¯ã·ã§ã³ãããªãããã®ä¸ã«ç´°ããªè¨å®ãè¨è¿°ãã¦ããã
Host server1 HostName 192.168.11.101 Port 2222 User nauthiz IdentityFile ~/.ssh/server1/id_rsa Host server2 HostName 192.168.11.102 Port 2222 User nauthiz IdentityFile ~/.ssh/server2/id_rsa
Hostã®ååã¯sshã§ãã¡ã¤ã³ã®ä»£ããã«æå®ã§ããã
ä¾ãã°ãsshã§server1ã¨åä»ããHostã«æ¥ç¶ããããã°æ¬¡ã®ããã«æå®ããã°ããã
$ ssh server1
ãããã©ã¡ã¼ã¿ãä¸æ¸ãããããã°ãã³ãã³ãã©ã¤ã³ã®ãªãã·ã§ã³ã§æå®ãã¦ããããããã¡ããåªå ããããã
ã¯ã¤ã«ãã«ã¼ã
Hostã»ã¯ã·ã§ã³ã®ååã¯ã*ã§å
¨ä½ãããã¯é¨åçã«ã¯ã¤ã«ãã«ã¼ãæå®ãå¯è½ã ã
ç¹ã«å
±éè¨å®ã¨ãã¦*ãæå®ãã¦ããã¨ä¾¿å©ã ããã
ãã ãã*ãæå®ããHostã¯æå¾ã«æ¸ããã¨ã
åãã©ã¡ã¼ã¿ã¯ãããããããã¹ãããé ã«æ¡ç¨ãããããã
æåã«*ãæå®ããã¨ä»¥éã«Hostãç¡è¦ããã¦ãã¾ãã
Host *.sample.co.jp # *.sample.co.jpã«æ¥ç¶ããå ´åã®å ±éè¨å® Host * # å ¨æ¥ç¶å ã®å ±éè¨å®
Hostæ¯ã®è¨å®
HostName | æ¥ç¶å ã®ãã¡ã¤ã³ãIPã¢ãã¬ã¹ | ä¾) 192.168.11.102 |
---|---|---|
Port | ãã¼ã | ä¾) 22 |
User | ãã°ã¤ã³ããã¦ã¼ã¶ | ä¾) nauthiz |
IdentityFile | å ¬ééµèªè¨¼ã«ä½¿ç¨ããç§å¯éµ | ä¾) ~/.ssh/id_rsa |
è¨å®ã§ãããã©ã¡ã¼ã¿ã¯ä»ã«ããããããã®ã§è©³ããã¯æ¬¡ãåç §ã
$ man ssh_config