SSHã®å ¬ééµãä½æãGithubã«ç»é²ããæé
å½è¨äºã®å 容ã¯ä»¥ä¸ã®ãã¼ã¸ã¨ã»ã¼åæ§ã¨ãªãã¾ãã
ãã¼ããã¼ã¨ãããã¯ã©ã¤ã¢ã³ãã®ä¼æ¥ã«gitãå§ãã¦ã2社ã»ã©svnãã移è¡ãã¦ããã£ããã¨ã®ãã @mon_sat ã§ãã
Githubã®ãã«ãã«ã¯æçãªãã¼ã¸ãå¤ãã§ãããä¸è¨ã®ãã¼ã¸ããã®ã²ã¨ã¤ã§ããã
æè¿é»ãç»é¢ã使ããã«gitã使ãç³»ã®è¨äºãåå¼·ä¼ãå¢ãã¦ãã¾ãã¦ããã 1ç¹ãç§å¯éµããå ¬ééµããã®ã¨ããã¯ããã¯ãããªãå ´åãããã®ãã¨æãã¾ãã
ã¨ããããã§SSHã®å ¬ééµãä½æãGithubã«ç»é²ããæé ãä¸è¨ã®webãã¼ã¸ããã¨ã«ï¼æ¥æ¬èªã§ï¼ã¾ã¨ãã¦ã¿ã¾ããã
åºæ¬çãªè§£èª¬
ãã®è¨äºã§è¨è¼ã®æé ããªãå¿
è¦ãç解ãã¦ããªãæ¹ã®ããã«ãç°¡åãªèª¬æããããã¾ãã
ï¼ç解ãã¦ããæ¹ã¯ãèªã¿é£ã°ãã¦ããã ãã¦æ§ãã¾ããï¼
ç§å¯éµã»å ¬ééµã¨ã¯
ç§å¯éµã»å ¬ééµã¨ã¯ãéµäº¤ææ¹å¼ã®èªè¨¼ã®ããã«ä½¿ã2ã¤ã®ãã¡ã¤ã«ï¼ãã¼ã¿ï¼ã§ãã
ç§å¯éµã®ãã¡ã¤ã«ã¯ããªãã ãããè¦ãããªãããã«æ±ããå ¬ééµã®ãã¡ã¤ã«ã¯èªè¨¼ãè¡ãç¸æå´ï¼ãµã¼ãã¼ãWebãµã¤ãçãGithubããã®ã²ã¨ã¤ï¼ã«é ãã¾ãã
ç§å¯éµã¨å ¬ééµã¯ãã¢ã«ãªã£ã¦ãã¦ãç§å¯éµãåå¨ãããã·ã³ã®ã¿ãããããWebãµã¤ãï¼ããµã¼ãã¼ï¼çãå©ç¨ã§ãã¾ããã ï¼IDãã¹ã¯ã¼ãã®ä»£ããã¨ãªããWebãµã¤ãããããªãã§ãããã¨ãã確èªããã®ã§ãï¼
è¤æ°ã®ãã·ã³ãå©ç¨ããå ´åã¯ããããã§éµãã¡ã¤ã«ãä½æããè¤æ°ã®å
¬ééµãé ãããã¨ã«ãªãã¾ãã
ç§å¯éµã¨å
¬ééµã¯å¯¾ã«ãªã£ã¦ãã¾ãã
gitï¼â Githubï¼ã¯ãããã«sshã使ç¨ãã¦ä»ãµã¼ãã¼ä¸ã®ãªã¢ã¼ããªãã¸ããªã¨ããã¨ããã¾ãã
sshã®éä¿¡ã§ã¯ãéµäº¤ææ¹å¼ã«ããèªè¨¼ã«ããIDãã¹ã¯ã¼ããããã»ãã¥ã¢ãªæ¥ç¶ãå¯è½ã§ãã
åºæ¬çãªæé
ãããã以ä¸ã®ãããªæµãã«ãªãã¾ã
å ¬ééµã®æç¡ã確èªãã
Macã®ããã¯ã¿ã¼ããã«ã¨ããã¢ããªããWindowsã®ããã¯Git Bashãã²ããã¦ãã ããã
以ä¸ã®ã³ãã³ããå ¥åãã¾ãã
ï¼å¿µã®ããè£è¶³ãå é ã® $ ã¯ã³ãã³ãã§ã¯ããã¾ããããã以éãå®è¡ããã¹ãã³ãã³ãã«ãªãã¾ãï¼
$ ls ~/.ssh
ããã§ä»¥ä¸ã®ãããªãµãã¤ã®ãã¡ã¤ã«ãåå¨ããå ´åã¯ããã§ã«ç§å¯éµã»å ¬ééµã¯ä½æããã¦ãã¾ãã®ã§ã次ã®ä½æ¥ã¯é£ã°ãã¦ããã ãã¦åé¡ããã¾ããã
id_rsa id_rsa.pub
ãªã .pub ã¨ããæ¡å¼µåã®ãã¡ã¤ã«ãå ¬ééµã®ãã¡ã¤ã«ã§ãã
ç§å¯éµã»å ¬ééµã®ãã¢ãçæãã
$ ssh-keygen -t rsa -C "[email protected]"
ã¡ã¼ã«ã¢ãã¬ã¹ã¯èªåã®ã¡ã¢ãã«å¤æ´ãã¦ãã ããï¼ä¾ï¼ ssh-keygen -t rsa -C "[email protected]" ï¼
å®è¡ããã¨ä»¥ä¸ã®3ã¤ã®å ¥åãæ±ãããã¾ããããã¹ã¦ Enter(return) ã§å®ç¨ä¸æ§ãã¾ããã
- éµãã¡ã¤ã«ãä¿åãããã©ã«ã
- ãã¹ãã¬ã¼ãº
- ãã¹ãã¬ã¼ãºï¼ç¢ºèªç¨ï¼
ãããã¹ãã¬ã¼ãºãè¨å®ããå ´åã¯ä»¥ä¸ã®ã³ãã³ããå®è¡ãããã¹ãã¬ã¼ãºã®å ¥åãçç¥ããè¨å®ãå¯è½ã§ãã
$ ssh-add ~/.ssh/id_rsa
å ¬ééµãGithubã«ç»é²ãã
å ¬ééµã®å 容ãã¯ãªãããã¼ãã«ã³ãã¼ãã¾ã
Macã®å ´å
$ pbcopy < ~/.ssh/id_rsa.pub
Windows(Git Bash)ã®å ´å
$ clip < ~/.ssh/id_rsa.pub
Githubã«ç»é²ãã
SSH Keysã®è¨å®ãã¼ã¸
- å³ä¸ã®å·¥å ·ã¢ã¤ã³ã³ãã Account Settings ã®ãã¼ã¸ãéãã¾ã
- å·¦å´ã®ã¡ãã¥ã¼ãã SSH Keys ã®ãã¼ã¸ãéãã¾ã
- 赤ãä¸ç·ã®ä½ç½®ã«ãã [Add SSH Key] ã®ãã¿ã³ãã¯ãªãã¯
å ¬ééµãç»é²ãã
- Titleã¯ä»»æã®å称ãå ¥åï¼ã©ã®PCã®éµããåºå¥ããããã®å称ãªã©ï¼MacBook Airãªã©ï¼
- Keyã®å ¥åæ¬ã§ã¯ãªãããã¼ãã®å 容ã Paste ããï¼â+v / Ctrl+vçï¼
- Add Key ãã¿ã³ãã¯ãªãã¯
試ãã«æ¥ç¶ãã¦ã¿ã
以ä¸ã§çµäºã§ãã
ååã®ã¿ç¸æã®ãµã¼ãã¼ã確èªããä½æ¥ãããã¾ãã®ã§ããã¡ã©è©¦ãã«æ¥ç¶ãã¦ã¿ãã¨ããã§ãããã
$ ssh -T [email protected]
ã¤ãã®ããã«è¡¨ç¤ºãããããè½ã¡çã㦠yes
ã¨å
¥åãã¦ãã ãã
The authenticity of host 'github.com (207.97.227.239)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)?
æ¥ç¶ã«æåããã¨ãã¤ãã®ãããªã¡ãã»ã¼ã¸ã«ãªãã¯ãã§ã
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
ããã§èªåã®ãªãã¸ããªã«èªç±ã«ã¢ã¯ã»ã¹ã§ããããã«ãªãã¾ãã
Pushããã Pullããã ãèªç±ã«ã©ããï¼
ï¼ãã¾ãï¼@mon_satã®ãã³ãã³ç¸è«å®¤
ï¼ç¸è«å å®¹ï¼ ãããã¯é»ãç»é¢ã®æ±ãã«ãã¤ã¾ã§ãã£ã¦ãæ £ãã¾ããã ããã®Web製ä½è ã¨ãã¦ãããããé»ãç»é¢ããã使ããããã«ãªãããã®ã§ããã©ããããè¯ãã§ããããï¼
é»ãç»é¢ãé£ããæããã®ã¯ãã¿ã¼ããã«ã®ããã©ã«ãã¯ç½ãç»é¢ãªã®ã«ãèªåã§é»ããã¦è «ãç©ã«ããããããªå¯¾å¿ãã¦ãããããï¼
ãããã®ã