LoginSignup
2
2

More than 5 years have passed since last update.

GitHubにsshで接続する方法

Posted at

事ある毎にググっている気がするので、備忘録として残しておきます。

鍵の作成

$ ssh-keygen -t rsa -C "メールアドレス"
  • 鍵の保存パス
  • 鍵のパスフレーズ(設定しなくてもいい)

上記を聞かれるので、入力する。

$ chmod 600 ${作成した秘密鍵}

作成した秘密鍵のパーミッションを600にしておく。

公開鍵の登録

# cat ${作成した公開鍵}

上記で表示された文字列をGitHubに登録する。

  1. GitHubにログイン
  2. ユーザアイコンから「Settings」を選択
  3. 「SSH keys」の項目から、catした内容の文字列を登録する

.ssh/configに接続情報を登録する

ローカルマシンの「.ssh/config」に以下を設定する。

Host github.com
  HostName github.com
  IdentityFile ${作成した秘密鍵}
  User git

以下のコマンドを実行して接続確認が取れれば終了。

$ ssh -T git@github.com

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