LoginSignup
4
1

More than 5 years have passed since last update.

Githubにdeploy用の鍵を追加する

Posted at

リポジトリごとに設定できて、git cloneとかができる。
そんなものがあったなんて知らなかった。専用のユーザーとかを作らなくて(・∀・)イイ!!

やり方はデプロイユーザーで鍵を作って登録するだけです。
GHEにもあるのかなぁ。

1. デプロイユーザーで鍵を作ります

すでにある場合はソレを使ってもよい。

[ec2-user@ip-10-21-12-201 ~]$ ssh-keygen -t ed25519
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/ec2-user/.ssh/id_ed25519): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/ec2-user/.ssh/id_ed25519.
Your public key has been saved in /home/ec2-user/.ssh/id_ed25519.pub.
The key fingerprint is:
SHA256:/qSeuz07bmLo+8coz9FLr1SGQN8OR3d2Ow3yxyte4/c ec2-user@ip-10-21-12-201.ap-northeast-1.compute.internal
The key's randomart image is:
+--[ED25519 256]--+
|        .   o o +|
|       . . o + =+|
|        . o o .o+|
|         . =   .o|
|        S . +. + |
|       . . o. + .|
|       .oo=  . ..|
|      o.+X*o    o|
|     .oBXBB=.   E|
+----[SHA256]-----+

2. 公開鍵をgithubに登録します。

SettingsからのDeploy keysからのAdd deploy key

image.png

こんな感じになります。

image.png

3. clone pullできます。

[ec2-user@ip-10-21-12-201 workspace]$ git clone git@github.com:mercury-inc-cc/gascenter.git
Cloning into 'gascenter'...
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5: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)? yes
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.
remote: Enumerating objects: 368, done.
remote: Counting objects: 100% (368/368), done.
remote: Compressing objects: 100% (239/239), done.
remote: Total 2631 (delta 187), reused 288 (delta 115), pack-reused 2263
Receiving objects: 100% (2631/2631), 4.98 MiB | 6.22 MiB/s, done.
Resolving deltas: 100% (744/744), done.
[ec2-user@ip-10-21-12-201 workspace]$ ll
total 0
drwxrwxr-x 9 ec2-user ec2-user 277 Mar 12 08:20 gascenter

push権限もつけられるみたい。いるの?いるか?いらんような?

GHEにもありました!
image.png

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1