部分內容參考:http://git.mydoc.io/?t=154712
1、在電腦桌面上右鍵,選擇git Base here
2、生成ssh公鑰
ssh-keygen -t rsa -C"xxxxx@xxxxx.com"# Generating public/private rsa key pair...# 三次回車即可生成 ssh key
xxxxx@xxxxxx是自己設定的郵箱。
3、查看當前目錄下的文件
ls -al ~/.sh
在當前目錄下,id_rsa是私鑰,id_rsa.pub是公鑰。
4、查看公鑰
查看你的public key,並把他添加到 Git @ OSC SSH key添加地址
cat ~/.ssh/id_rsa.pub # ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....
id_rsa.pub是公鑰。文件中的內容就是公鑰。
5、把公鑰添加到github或oschina
在公鑰的位置,復制上id_rsa.pub文件的內容。
6、驗證oschina的公鑰是否設置成功(這一步可忽略)
添加后,在終端(Terminal)中輸入
ssh -T git@git.oschina.net
若返回
Welcome to Git@OSC, yourname!