Preface#
The ssh key has expired again, and every time I need to re-add it, I have to refer back to the documentation. So, I decided to write a convenient guide for myself.
Steps#
Using Ubuntu as an example
$ ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
$ #Enter name
$ Enter passphrase (empty for no passphrase): Enter password
$ Enter same passphrase again: Re-enter password
If you press Enter directly at the name input, the following will be output
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256: ....code..... root@system
Use the cat command directly
cat ~/.ssh/id_rsa.pub
Copy the output directly to the "Add new SSH Key" section on GitHub.
Testing#
$ ssh -T git@github.com
Issues#
There may be connectivity issues in China, you can try changing the DNS.