コンテンツにスキップ

GitHubのプライベートリポジトリをcloneする

いつも忘れるのでメモ。

ed25519でssh-keygenする

ssh-keygen -t ed25519-sk -C "your_email@example.com"

↑メールアドレスはnoreplyのものでOK

~/.ssh/config
Host github.com
  HostName github.com
  IdentityFile ~/.ssh/id_ed25519
  User git
  AddKeysToAgent yes

これも必要かも?

ssh-add ~/.ssh/id_ed25519
ssh-add -l #確認

GitHubで自分のアカウントに公開鍵を追加

プロファイル > SSH and GPG keys > New SSH Key

Warning

コピペするときはターミナルで改行されないように表示しておかないとハッシュが壊れるので注意

テストしてgit clone

ssh -T git@github.com

問題なければ git clone できる

git clone git@github.com:<github username>/<repo name>.git