0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHubでSSHキーを設定する

Last updated at Posted at 2021-12-03

事前準備

  • GitHubに登録済みであること
    ※後日リンク追加

1. 秘密鍵/公開鍵を作成

鍵を保存するディレクトリ作成。すでに存在する場合は作成不要。

$ mkdir ~/.ssh

秘密鍵/公開鍵ペアを作成(実行場所はどこでも)。

$ ssh-keygen -t ed25519
Enter file in which to save the key (/Users/(username)/.ssh/id_ed25519):
Created directory '/Users/(username)/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

コマンドを実行したら、Enterを3回押す。
保存場所とパスフレーズの設定だが今回はしない。
鍵ペアが~/.sshに作成される。

秘密鍵:id_ed25519
公開鍵:id_ed25519.pub

2. GitHubに公開鍵を設定

公開鍵をクリップボードにコピー。

$ pbcopy < ~/.ssh/id_ed25519.pub 

GitHubに公開鍵を設定。

  1. GitHubのssh設定を開く
  2. New SSH keyをクリック
  3. Titleに適当な名前を入力
  4. Keyに先ほどコピーした公開鍵をペースト
  5. Add SSH keyをクリック

GitHubにSSH接続できることを確認。

$ ssh -T git@github.com
Hi (account name)! You've successfully authenticated, but GitHub does not provide shell access.

関連

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?