社å
ã® Gitãµã¼ããã社å
ã® Linuxãµã¼ããGitHub ã« SSH ã§æ¥ç¶ããã¨ããªã©ãã¦ã¼ã¶åã¨ãã¹ã¯ã¼ããå
¥åããªããã°ãªããªãã¨æãã¾ãããã¡ãããå¿
è¦ã«å¿ãã¦ããã¹ã¯ã¼ãã¯å¿
è¦ã ã¨æãã¾ããããã¼ã«ã«ãª Gitãµã¼ãã«æ¥ç¶ããã®ã«ããããªã«å³å¯ã«éç¨ããå¿
è¦ã¯ãªãå ´åãããã¾ãããã
ç¹ã«ãGit ã®å ´åãpush ãããã³ã«ãã¦ã¼ã¶åã¨ãã¹ã¯ã¼ããå
¥åããã®ã¯ãã¨ã¦ãé¢åã§ãã
ã¨ãããã¨ã§ãä»åã¯ãã¦ã¼ã¶åã¨ãã¹ã¯ã¼ããå
¥åããªãã¦ãããæ¹æ³ãæ¸ãã¾ãããã¤ãå¿ãã¦ãã¾ã£ã¦ãWeb ãã¦ãã¦ããã¦ãã¾ãã®ã§ï¼ç¬ï¼ã
ä¸å¿ãããã«æ¸ããã¨ã¯ãã»ãã¥ãªãã£çã«åé¡ãªãå ´åã«éã£ã¦ä½¿ããæ¹æ³ãªã®ã§ãããã¯ã注æé ããã°ã¨æãã¾ãã
ããã§ã¯ããã£ã¦ããã¾ãã
ã¯ããã«
ããããªã±ã¼ã¹ãããã¨æãã¾ãã®ã§ã1ã¤ãã¤ãåãã¦æ¸ãã¦ãããã¨æãã¾ãã
ç°å¢ã¯ãLinuxï¼UbuntuãParrotOSï¼ã使ã£ã¦ãã¾ãã
å
¬ééµã¨ç§å¯éµãæºåãã
ç¾ç¶ããã使ããã¦ããèªè¨¼æ¹å¼ã¯ããã¹ã¯ã¼ãã«ããèªè¨¼ã¨ãå
¬ééµã¨ç§å¯éµã使ã£ãæ¹æ³ã ã¨æãã¾ãã
ãã¹ã¯ã¼ãã使ã£ãèªè¨¼ã§ããã¹ã¯ã¼ããå
¥åããªãæ¹æ³ã¯ãä½ããã®ãã¼ã«ã使ããªãã¨é£ããã§ãã
å
¬ééµã¨ç§å¯éµã使ã£ãèªè¨¼æ¹å¼ã¨ã¯ãç§å¯éµã¯èªåã ããæã£ã¦ç½®ããå
¬ééµãæ¥ç¶å
ã®ãµã¼ãã«ç½®ãã¦ããã¾ããããã¨ãç§å¯éµãæã£ãèªåã ãããèªè¨¼ããã¹ã§ããã¨ããä»çµã¿ã§ãã
ããã§ã¯ãå
¬ééµã¨ç§å¯éµã使ã£ã¦ããã¹ã¯ã¼ããå
¥åããªãã§ããæ¹æ³ã説æãã¾ãã
ã§ã¯ãå
¬ééµã¨ç§å¯éµã®ä½ææ¹æ³ã§ããããããªæ¹æ³ãããã¨æãã¾ãããéµé·ããããã種é¡ãããã¾ãããããã§ã¯ãæãç°¡åã«ä½ããæ¹æ³ã«ãã¦ãã¾ãã
ã¾ãããã¼ã ãã£ã¬ã¯ããªç´ä¸ã«ã.ssh ãã£ã¬ã¯ããªãåå¨ããå ´åãããã«ãid_rsaï¼ç§å¯éµï¼ã¨ id_rsa.pubï¼å
¬ééµï¼ã¨ãããã¡ã¤ã«ãç¡ããã¨ã確èªãã¦ãã ãããå
¬ééµã¨ç§å¯éµããããã®ãã¡ã¤ã«åã§ä½ãããã®ã§ãä¸æ¸ããã¦ãã¾ãããã§ãã
ãã¡ãããå¥ã®å ´æã«ãå¥ã®ãã¡ã¤ã«åã§ä½æãããã¨ãã§ãã¾ããããã®å ´åï¼ç§å¯éµã ~/.ssh/id_rsa ã¨ãããã¹ä»¥å¤ã«é
ç½®ããå ´åï¼ã¯ã.ssh ãã£ã¬ã¯ããªã« configãã¡ã¤ã«ãç¨æãã¦ãç§å¯éµã®å ´æã示ãå¿
è¦ãããã¾ããããã¯ãç°å¢ãã¨ã« configãã¡ã¤ã«ãç¨æãããã¨ã«ãªãããã®è¨äºã®è¶£æ¨ã«åããªãã®ã§ããã®èª¬æã¯ä»ã®ãµã¤ããè¦ã¦é ããã°ã¨æãã¾ããããã§ã¯ãconfigãã¡ã¤ã«ç¡ãã§ããã¹ã¯ã¼ãå
¥åããã«æ¥ç¶ã§ããæ¹æ³ãæ¸ãã¾ãã
ã§ã¯ãä½ææ¹æ³ã§ãã1ã³ãã³ãã§ã³ãã³ãã©ã¤ã³å¼æ°ãä¸è¦ã§ãããã¹ã¯ã¼ãã¨ããã¹ã¯ã¼ãã®ç¢ºèªã¨ããªãããã1åãã¹ã¯ã¼ãã«ã¤ãã¦ãåè¨3åèããã¾ããããã¹ã¦ Enterãã¼ãæ¼ãã¦ãã¹ã¯ã¼ããç¡ãã§ä½æãã¾ãã
ããã§ãã¹ã¯ã¼ããè¨å®ããã¨ãç§å¯éµã使ããã³ã«ããã¹ã¯ã¼ããèããã¦ãã¾ãã¾ãã
ssh-agent ã使ãã°ãæåã®1åã ããã¹ã¯ã¼ããèããã¦ããã以éã¯èãããªããªãã¾ããããããã ssh-agent ãèµ·åãã¦ãç§å¯éµãç»é²ããã®ã«ã³ãã³ãå
¥åãå¿
è¦ã§ããããé¢åã§ãã
.bashrc ãªã©ã«ãssh-agent ãèµ·åããããã«ãã¦ããã°ãèµ·åã®æéã¯çãã¾ãããããããã¨ããã°ã¤ã³ã«å°ãæéããããããã«ãªãã¾ãããæ¯åç§å¯éµã使ãããã§ããªãã®ã«ããã°ã¤ã³æã«ç§å¯éµã®ãã¹ã¯ã¼ããå
¥åããã®ã¯é¢åã§ãã
ãã¹ã¯ã¼ããå
¥åããªãã¦ããç°å¢ã«ããã®ã¯ããªããªãé£ããã§ãã
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa
Your public key has been saved in /home/user/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:EztWOA879kcyRIw+CIICXCDT9ujnuW9KZBBLTSsjkoI user@parrot
The key's randomart image is:
+---[RSA 3072]----+
|*+=+. o. |
|==+oo. .o. |
|E.=+.. o= o |
|o..+. . oX |
| . o S.+ . |
| .o. o = + |
| o.. . . |
| .o . . |
| o=. |
+----[SHA256]-----+
$ ll ~/.ssh
total 16K
drwx------ 1 user user 84 Aug 24 21:22 ./
drwxr-xr-x 1 user user 1.8K Aug 24 21:15 ../
-rw------- 1 user user 2.6K Aug 24 20:56 id_rsa
-rw-r--r-- 1 user user 565 Aug 24 20:56 id_rsa.pub
-rw------- 1 user user 1.5K Aug 24 20:59 known_hosts
-rw------- 1 user user 648 Aug 24 20:59 known_hosts.old
å
¬ééµã¨ç§å¯éµããRSA-SHA2 ã§ä½æããã¾ãããSHA-1 ã¯æ°å¹´åã«éæ¨å¥¨ã«ãªã£ãã®ã§ãç¾å¨ã¯ããã©ã«ãã§ãSHA-2 ã使ãããããã§ãã
ãã® .ssh ãã£ã¬ã¯ããªã¯ããã¼ããã·ã§ã³ã 700 ã§ãããã¨ãå¿
è¦ã§ããã¾ããç§å¯éµï¼id_rsaï¼ã¯ããã¼ããã·ã§ã³ã 600 ã§ãããã¨ãå¿
è¦ã§ããä¸å¿ãããã§ç¢ºèªãã¦ãããæ¹ãããã§ãã
ã§ã¯ããã® 2ãã¡ã¤ã«ï¼id_rsa 㨠id_rsa.pubï¼ã使ãã¾ããã¦ããã¾ãã
GitHubã«ãã¹ã¯ã¼ããå
¥åããã«pushã¨ãpullããæ¹æ³
GitHub ã«å
ã»ã©ä½ã£ãå
¬ééµãç»é²ãã¾ãããããããã¨ã§ãã¹ã¯ã¼ããæ±ããããªããªãã¾ãã
GitHubã«å
¬ééµãç»é²ããæ¹æ³
GitHub ã®èªåã®ãªãã¸ããªã«ã¢ã¯ã»ã¹ãã¾ããå³ä¸ã«ã¢ã¤ã³ã³ãããã®ã§ããããã¯ãªãã¯ãã¦ãSettings ãã¯ãªãã¯ãã¾ãã
以ä¸ã®ç»é¢ã«ãªãã¨æãã®ã§ãSSH and GPG keys ã¨ããã¨ãããã¯ãªãã¯ãã¾ãã
次ã¯ã以ä¸ã®ç»é¢ã«ãªãã®ã§ãå³å´ã® New SSH key ãã¯ãªãã¯ãã¾ãã
Title ã¯ä»»æã®ååãè¨å®ã§ããã®ã§ãä»åç»é²ããå
¬ééµãèå¥ã§ãããããªååãæã¾ããã¨æãã¾ããKey-type 㯠Authentication Key ã®ã¾ã¾ã§å¤§ä¸å¤«ã§ããKey ã®ã¨ããã«ã¯ãå
ã»ã©ä½æããå
¬ééµã cat ã¨ãã§åºåãã¦ãå
¨ã¦ãã³ãã¼ãã¦è²¼ãä»ãã¾ããããã¾ã§å
¥åã§ããããAdd SSH Key ãã¯ãªãã¯ãã¾ãã
以ä¸ã®ããã«ãYou have successfully added the key 'no-password'. ã¨åºã¦ããã°æåã§ãã
å
¬ééµãæå¹ã«ãªã£ã¦ãããããã§ãã¯
ç»é²ããå
¬ééµãæå¹ã«åãã¦ãããã確èªãã¾ããç§å¯éµãé
ç½®ãã¦ã Linux ã§ä»¥ä¸ãå
¥åãã¾ãã
$ ssh -T [email protected]
$ ssh -T [email protected]
Hi dk0893! You've successfully authenticated, but GitHub does not provide shell access.
ãã®ãããªã¡ãã»ã¼ã¸ãåºãã°ãã¡ããã¨å
¬ééµã¨ç§å¯éµã®èªè¨¼ã¯åºæ¥ã¦ãã¾ãã
ãã¼ã«ã«ãªãã¸ããªã®ãªã¢ã¼ãæ¥ç¶å
ã確èªãã
ãã®æç¹ã§ãpushãpull ã§ãã¹ã¯ã¼ããèãããªãç¶æ
ã«ãªã£ã¦ããã°ããã®é
ç®ã¯å¿
è¦ããã¾ããããããã¦ã¼ã¶åã¨ãã¹ã¯ã¼ããèãããç¶æ
ãªãã以ä¸ãé²ãã¦ãã ããã
ç§å¯éµãé
ç½®ãã¦ãã Linux ã«ããã® GitHub ã®ãã¼ã«ã«ãªãªãã¸ããªãããã¨æãã¾ããç¡ãå ´åã¯ã¯ãã¼ã³ãã¦ãã確èªãã¦ãã ããã
Git ã«ã¯ãHTTPSæ¥ç¶ããSSHæ¥ç¶ãããã¾ããHTTPSæ¥ç¶ã«ãªã£ã¦ããã¨ãå
¬ééµèªè¨¼ã§ã¯ãªãããã¹ã¯ã¼ãèªè¨¼ãæå¹ã«ãªãå ´åãããã¾ãã®ã§ãããã§ç¢ºèªãã¾ãã
以ä¸ã®ããã«ãªã£ã¦ããããHTTPæ¥ç¶ã§ãã
$ git remote -v
origin https://github.com/dk0893/experiment.git (fetch)
origin https://github.com/dk0893/experiment.git (push)
以ä¸ã®ããã«ãªã£ã¦ããããSSHæ¥ç¶ã§ãã
$ git remote -v
origin [email protected]:dk0893/experiment.git (fetch)
origin [email protected]:dk0893/experiment.git (push)
ãããHTTPSæ¥ç¶ã«ãªã£ã¦ãããã以ä¸ã®ããã«ãã¦ãSSHæ¥ç¶ã«å¤æ´ãã¦ãå度è¨å®ã確èªãã¦ãã ããã
$ git remote set-url origin [email protected]:dk0893/experiment.git
$ git remote -v
origin [email protected]:dk0893/experiment.git (fetch)
origin [email protected]:dk0893/experiment.git (push)
ããã§ããã¹ã¯ã¼ããä¸åå
¥åããã«ãGitHub ã« pushãpull åºæ¥ãããã«ãªã£ãã¨æãã¾ãã
Gitãµã¼ãã«ãã¹ã¯ã¼ããå
¥åããã«pushã¨ãpullããæ¹æ³
Git ã® pushãpull ã¨ããã¿ã¤ãã«ã¨ãªã£ã¦ã¾ãããããã¯çµå±ãSSHãã°ã¤ã³ããã¹ã¯ã¼ããå
¥åããã«åºæ¥ãããã«ãããã¨ãæå³ãã¾ãã
åºæ¬çã«ã¯ãGitHub ã¨åããã¨ããã¾ããç§å¯éµã .ssh ãã£ã¬ã¯ããªã«é
ç½®ãã PC ãããå
¬ééµã Gitãµã¼ãã«ç»é²ãã¾ãã
ç°¡åãªæ¹æ³ã¯ãssh-copy-id ã³ãã³ãã使ãã¾ãã-i ã®å¾ã«ãå
¬ééµã®ãã¹ãæå®ãã¾ãããã®å¾ãã¯ãssh ã§æ¥ç¶ããã¨ãã¨åãã§ãã¦ã¼ã¶å@æ¥ç¶å
ãã¹ãã®IPã¢ãã¬ã¹ï¼ååã§ã¢ã¯ã»ã¹ã§ãããªããã¹ãåï¼ã§ãããã®ã¨ãã¯ãã¾ã å
¬ééµãç»é²ããåãªã®ã§ããã¹ã¯ã¼ããèããã¾ãã
$ ssh-copy-id -i ~/.ssh/id_rsa.pub wasbook@192.168.56.101
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/user/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
wasbook@192.168.56.101's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'wasbook@192.168.56.101'"
and check to make sure that only the key(s) you wanted were added.
æåããã¨ãsshæ¥ç¶ã§ãã¹ã¯ã¼ããèãããªããªãã¾ãããGitãµã¼ãã« pushãpull ããã¨ãããã¹ã¯ã¼ããèãããªããªãã¾ãã
ããããã¾ããããªãå ´åã¯ãä¸ã® Git ã®ã¢ã¯ã»ã¹æ¹æ³ã SSHæ¥ç¶ã«ãªã£ã¦ãããã¨ã確èªãã¦ãã¨ãããèªãã§ãã ããã
WindowsããLinuxã«Git BASHã§SSHæ¥ç¶ããã¨ãã«ãã¹ã¯ã¼ããå
¥åããªãæ¹æ³
æé 㯠Linux ã¨å
¨ãåãã§ããssh-copy-id ã§å
¬ééµã SSHãã°ã¤ã³ããã Linux ã«ç»é²ãã¦ãç§å¯éµï¼id_rsaï¼ã .ssh ãã£ã¬ã¯ããªã«èµ·ãã¾ãã
$ ssh-copy-id -i /c/Users/XXX/.ssh/id_rsa.pub user@192.168.56.105
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/c/Users/dk089/.ssh/id_rsa.pub"
The authenticity of host '192.168.56.105 (192.168.56.105)' can't be established.
ED25519 key fingerprint is SHA256:immrVRNX/maG7juQuesI1+76Mdhtn3KFJ1QoeBhBlUs.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
[email protected]'s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '[email protected]'"
and check to make sure that only the key(s) you wanted were added.
ã§ã¯ããã°ã¤ã³ãã¦ã¿ã¾ãã
$ ssh [email protected]
Linux parrot 6.5.0-13parrot1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.5.13-1parrot1 (2023-12-19) x86_64
____ _ ____
| _ \ __ _ _ __ _ __ ___ | |_ / ___| ___ ___
| |_) / _` | '__| '__/ _ \| __| \___ \ / _ \/ __|
| __/ (_| | | | | | (_) | |_ ___) | __/ (__
|_| \__,_|_| |_| \___/ \__| |____/ \___|\___|
The programs included with the Parrot GNU/Linux are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Parrot GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Aug 24 23:02:46 2024 from 192.168.56.1
: no key sequence terminator:
user@parrot(972) ~
[1:0]$
åé¡ãªããã°ã¤ã³ã§ãã¾ããã
WindowsããLinuxã«TeraTermã§SSHæ¥ç¶ããã¨ãã«ãã¹ã¯ã¼ããå
¥åããªãæ¹æ³
RSA-SHA2 ã« TeraTerm ã対å¿ãã¦ããã®ã¯ãv5.0ï¼ç¾å¨ã®ææ°ç㯠v5.2ï¼ãããªã®ã§ãv5.0 以éã®ãã¼ã¸ã§ã³ã使ãå ´åã¯ãåãå
¬ééµãç§å¯éµã使ãã¾ãããã¨ãåºæ¥ã¾ãã
以ä¸ã¯ãTeraTerm ã®å
¬å¼ãµã¤ãã§ãã
teratermproject.github.io
ãææ°ãªãªã¼ã¹ã¯ãGitHub ãããã¦ã³ãã¼ããããã¨ãã§ãã¾ããã®ãã¦ã³ãã¼ããã¯ãªãã¯ãã¾ãã
å°ãä¸ã«ã¹ã¯ãã¼ã«ããã¨ãteraterm-5.2.exe ããã¦ã³ãã¼ãã§ãã¾ããéå»ã®ãã¼ã¸ã§ã³ï¼v4ï¼ã¨ã¯å¥ã«ã¤ã³ã¹ãã¼ã«ãããã®ã§ãå
±åãå¯è½ãªããã§ãã
ã§ã¯ãå
¬ééµèªè¨¼ã試ãã¦ã¿ã¾ããTeraTerm v5 ãèµ·åãã¾ãããã¹ãã¢ãã¬ã¹ãå
¥åãã¦ããã¼ãçªå·ãªã©ãæ£ãããã確èªã§ããããOKãã¯ãªãã¯ãã¾ãã
次ã«ãã¦ã¼ã¶åã¨ç§å¯éµãæå®ãã¾ããã¦ã¼ã¶åãå
¥ããªãã¨ã¨ã©ã¼ã«ãªãã®ã§ã注æãã ããã
ç¡äºã«ãã°ã¤ã³ã§ãã¾ããã
ãããã«
ä»åã¯ãGit ãé¡æã«ãã¾ããããä»çµã¿ã¨ãã¦ã¯ãSSHãã°ã¤ã³ã§ãã¹ã¯ã¼ãã使ããªãæ¹æ³ã«ã¤ãã¦æ¸ãã¾ããã
ãã¹ã¯ã¼ããå
¥åããªããã¨ã¯ãã»ãã¥ãªãã£ã¨ãã¦ã¯åé¡ã¨ãªãã±ã¼ã¹ãããã®ã§ãå
å®ã«å¯¾å¿ããã¨ããã¨ãæãæãã¨ãããããã¾ã使ãåãããã¨ã大äºããªãã¨æãã¾ãã
ä»åã¯ãé·å¹´æç¨ããã¦é ãã¦ãã TeraTerm ã®ãã´ã使ããã¦é ãã¾ããããããã¨ããããã¾ãã
æå¾ã«ãªãã¾ããããã¨ã³ã¸ãã¢ã°ã«ã¼ãã®ã©ã³ãã³ã°ã«åå ä¸ã§ãã
æ°æ¥½ã«ãããã¨ãããããé¡ããããã¾ãð
ä»åã¯ä»¥ä¸ã§ãï¼
æå¾ã¾ã§ãèªã¿ããã ãããããã¨ããããã¾ããã