ubuntu獲取sshkey的方法:
1.打開終端命令行。
2.輸入以下命令。
ssh-keygen -t rsa -C "your_email@example.com" //your_email@example.com為你在GitHub或者GitLab注冊時的郵箱
2.執行后,終端會顯示如下結果,按回車保存。
Created directory '/Users/xxx/.ssh'.
Enter passphrase (empty for no passphrase):
3.提示設置 passphrase,設置成功后會顯示:
Your identification has been saved in /Users/xxx/.ssh/id_rsa.
Your public key has been saved in /Users/xxx/.ssh/id_rsa.pub.
The key fingerprint is:
16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48 your_email@example.com
The key's randomart image is:
心形圖形
4.接著在終端輸入以下命令:
ssh-add ~/.ssh/id_rsa
5.按要求填剛剛設置的passphrase,成功后會顯示:
Identity added: /Users/xxx/.ssh/id_rsa (/Users/xxx/.ssh/id_rsa)
6.最后再輸入以下命令就可以獲取你的sshkey了,命令如下:
cat /Users/xxx/.ssh/id_rsa.pub