SSH_KEY配置

生成公鑰

打開命令行終端輸入ssh-keygen -t rsa -C “username@example.com”,接下來點擊enter鍵即可(也可以輸入密碼)。

$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]  // 推薦使用默認地址
Enter passphrase (empty for no passphrase):

之后會提示想要存放公鑰的文件位置及密碼;文件位置不填的話就會默認為 /Users/you/.ssh/id_rsa



成功之后

Your identification has been saved in /Users/you/.ssh/id_rsa.
# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

本地打開 id_rsa.pub 文件,其內(nèi)容就是生成的公鑰內(nèi)容。

管理多個公鑰

如果需要使用多個賬戶建議生成多個公鑰,可以在.ssh/config文件中加上下邊一段

Host git.coding.net
User xxxx@email.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/coding_rsa  // 生成的非默認地址的公鑰存放點
最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內(nèi)容