LoginSignup
1
1

More than 5 years have passed since last update.

GitHubへの公開鍵登録の注意点

Posted at

鍵の名前を ssh-keygen -t rsaで作成して id_rsa(初期設定から)変えた場合は
$ssh -T git@github.comがうまくいかない
ssh接続の際「~/.ssh/id_rsa」、「~/.ssh/id_dsa」、「~/.ssh/identity」しかデフォルトでは見にいかないから。

~/.ssh/configに以下を追加しないといかない

Host github github.com
  HostName github.com
  IdentityFile ~/.ssh/id_rsa_git #変更したファイル名
  User git

これでうまくいく

$ ssh -T github.com
Hi username! You've successfully authenticated, but GitHub does not provide shell access.

すでにhttpでURL登録済みの場合は

$git remote set-url origin git@github.com:foobar/hogehoge.git

なお、リモートホストの確認は

$ git remote -v

鍵の中身のクリップボードへのコピーは

$ pbcopy < ~/.ssh/id_rsa.pub (Mac)
$ clip < ~/.ssh/id_rsa.pub (Windows)
1
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
1
1