1,SSHの鍵を作成する
Git Bashを立ち上げて、RSAキーペア(公開鍵と秘密鍵)を作る。
-b:長さ。デフォルトは2048(256バイト)だけど推奨は4096(512バイト)みたい。
-C:鍵の中に入るコメント。無くてもOKだけど、PCが識別できるコメントを入れておく。
$ ssh-keygen -t rsa -b 4096 -C "○○○○○"
どこに作るか聞かれる。
githubの鍵だということが分かるようにファイル名だけ変えておく。
Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/user/.ssh/id_rsa): /c/Users/user/.ssh/id_rsa_github
パスワードを2回聞かれるので入力すると、キーペアができる。(id_rsa_githubとid_rsa_github.pub)
あたりまえだけどgithubのログインパスワードとかとは全く関係ない。
Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/user/.ssh/id_rsa_github Your public key has been saved in /c/Users/user/.ssh/id_rsa_github.pub The key fingerprint is: SHA256:(略) ○○○○○ The key's randomart image is: +---[RSA 4096]----+ (略) +----[SHA256]-----+
Linuxとかの場合は、安全のためにここで秘密鍵(/c/Users/user/.ssh/id_rsa_github)のパーミッションを600にchmodするのがセオリーだが、今回はログインパス付きのWindowアカウント上なので特に何もしません。(chmodしても変わらない)
それと、公開鍵と秘密鍵が同じ.ssh/に配置された状態になるので、なんとなく公開鍵は別Dirに移してアーカイブにしておきます。