1.創(chuàng)建SSH Key
ssh-keygen -t rsa -C "你的郵箱賬號"
回車鍵后會有下面顯示:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/now/.ssh/id_rsa): '這里輸入文件名字 比如id_rsa'
然后會提示讓輸入密碼:這個密碼是 push時候的密碼 不是github的密碼
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
會有下面提示
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
SHA256:6z7Ya7lLkRKld266nSb6oKcAkCm0Sv/zSmud2R/U2uM you-mail@mail.com
The key's randomart image is:
+---[RSA 2048]----+
| . . |
|.o. o |
|=o o . . |
|= . o + . |
|o . . S o. . |
| . . . =. o |
| . +ooB. o o |
| ..o*B*+..o . |
| +=o*OB+. E |
+----[SHA256]-----+
這就創(chuàng)建完成了,然后找到id_rsa.pub文件 可以拖到瀏覽器查看文件內(nèi)容,復(fù)制憎妙。
2.把SSH Key添加到Github倉庫中
打開Github ->設(shè)置 –> SHH和GPG秘鑰 -> New SSH key
把獲取到秘鑰粘貼進去就ok了
3霜幼、驗證是否可用
在終端輸入:
ssh -T git@github.com
出現(xiàn)下面就可以用了
Hi 用戶名! You've successfully authenticated, but GitHub does not provide shell access.