以下のコマンドを使用して SSH キーを生成します
ssh-keygen -trsa -C user@xyz.com
Enterキーを押すだけで、要求するすべての入力にデフォルト値が適用されます
出力は次のようになります
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
/home/user/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa
Your public key has been saved in /home/user/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx user@xyz.com
The key's randomart image is:
+---[RSA xxxx]----+
| ..++xX*Ox |
| x..xx/+.x. + . |
|.. +..*+xx x + |
|... +x+o x. |
|x.. + +..x |
|xx.. x |
|... |
|x x |
|x x. |
+----[SHA256]------+
コマンドを使用してcat
、ssh キー ファイルの内容を端末に記録します (ここでは独自のパスを使用します)。
cat /home/user/.ssh/id_rsa.pub
出力は次のようになります
ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com
コンテンツをコピーして github アカウントに移動します。[アカウント設定] > [SSH と GPG キー] の設定に移動し、[] をクリックしてNew SSH key
、希望する名前を入力し、コピーしたコンテンツを値に貼り付けて保存します。これで、毎回ユーザー名とパスワードを使用せずに変更をコミットする準備が整いました。