前言#
ssh key 又過期了,每次重新添加都要回看 documentation,自己寫一個方便記的。
步驟#
以 Ubuntu 為例
$ 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 passphrase (empty for no passphrase): 輸入密碼
$Enter same passphrase again: 再次輸入密碼
如果在輸入名字處直接按回車會輸出如下
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
直接使用 cat 指令
cat ~/.ssh/id_rsa.pub
輸出直接複製到 GitHub 的 Add new SSH Key 中即可。
測試#
$ ssh -T git@github.com
問題#
可能存在國內無法連接問題,可嘗試更換 DNS