目的
- 自身の備忘のために本ページを記述する。
ゴール
- macOS上で公開鍵・秘密鍵を作成し、GitHubに設定、git clone ssh://...ができるようにする!
手順
- ホームディレクトリに.sshがなければ作成する(今回はあったのでスキップ)
hogehogenoiMac:~ hogehoge$ cd .ssh
hogehogenoiMac:.ssh hogehoge$ ls
known_hosts
- 鍵を作成する。
hogehogenoiMac:.ssh hogehoge$ ssh-keygen -t rsa -b 4096 -C "(メールアドレス)"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/hogehoge/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/hogehoge/.ssh/id_rsa.
Your public key has been saved in /Users/hogehoge/.ssh/id_rsa.pub.
- Githubの鍵設定の箇所にid_rsa.pubの内容を貼り付ける。

- 動作確認
hogehogenoiMac:repos hogehoge$ ssh -T git@github.com
# known_hostsに追加するか聞かれるので、yesを入力する
...
Hi (ユーザ名)! You've successfully authenticated, but GitHub does not provide shell access.
- git clone
hogehogenoiMac:repos hogehoge$ git clone git@github.com:(ユーザ名)/prj.git
Cloning into 'prj'...
...
Receiving objects: 100% (3/3), done.
以上。