$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file inwhich to save the key (/root/.ssh/id_rsa): sakkuntyo-mint #鍵の名前です、今回はLinuxMint用に作成したためこの名前 Enter passphrase (empty for no passphrase): #パスワード、無くても良い Enter same passphrase again: #パスワードの再確認 Your identification has been saved in sakkuntyo-mint. Your public key has been saved in sakkuntyo-mint.pub. The key fingerprint is: SHA256:7XG5j/GRtAxIs3/dkUxVIZDrcyG+6g7LVxqvNVK1bEg root@DESKTOP-2QSQU2N The key's randomart image is: +---[RSA 2048]----+ | .o. .=| | . . .| | oE.. . | | o.*+o+ .| | S Bo=+o+ | | o.O.* +o| | . .*oB * o| | . oooo.* . | | o+=o . o | +----[SHA256]-----+
鍵ファイルが出来た事を確認する
1 2
$ ls sakkuntyo-mint sakkuntyo-mint.pub
.pubが付いているのが公開鍵 ついていないのが秘密鍵
GitHubに配置する
github.comのsettingsを開く
「SHS and GPG keys」を開き、公開鍵の名前と公開鍵の内容を登録
Titleは何でも大丈夫
これで公開鍵が登録されました
sshクライアントにgitの設定を追加
~/.ssh/configを編集し、以下の4行を追加
1 2 3 4
Host git hostname github.com user git identityfile ~/.ssh/sakkuntyo-mint #秘密鍵のパス