LoginSignup
9
6

More than 5 years have passed since last update.

GitHubにSSH認証で接続する

Posted at

環境

・MacOS
・GitHub

SSH 認証キー(秘密鍵・公開鍵)の生成

ssh-keygen -t rsa -C "your-mail@address"
Enter file in which to save the key (/YourHome/.ssh/id_rsa):Enter押下
Enter passphrase (empty for no passphrase):任意のパスフレーズ
Enter same passphrase again:任意のパスフレーズ(上記設定値と同じもの)

ホーム配下に.ssh/id_rsa(秘密鍵)と.ssh/id_rsa.pub(公開鍵)が作成される。

公開鍵の登録

pbcopy < ~/.ssh/id_rsa.pub

クリップボードに公開鍵の内容がコピーされているので、GitHubへログイン

Add_new_SSH_keys.png

Titileは任意の値、Keyにクリップボードにコピーされている内容をそのままペーストする。「Add SSH Key」ボタン押下で登録完了

動作確認

ssh -T git@github.com

鍵生成時にパスフレーズを登録した場合は以下が表示されるのでパスフレーズを入力

Enter passphrase for key '/YourHome/.ssh/id_rsa':

以下が表示されればOK

Hi YourName You've successfully authenticated, but GitHub does not provide shell access.

参考

GitHub Help

9
6
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
9
6