部份內容參考:http://git.mydoc.io/?t=154712git
一、在電腦桌面上右鍵,選擇git Base heregithub
二、生成ssh公鑰ruby
ssh-keygen -t rsa -C"xxxxx@xxxxx.com"# Generating public/private rsa key pair...# 三次回車便可生成 ssh key
ssh
xxxxx@xxxxxx是本身設定的郵箱。spa
三、查看當前目錄下的文件.net
ls -al ~/.shcode
在當前目錄下,id_rsa是私鑰,id_rsa.pub是公鑰。regexp
四、查看公鑰get
查看你的public key,並把他添加到 Git @ OSC SSH key添加地址string
cat ~/.ssh/id_rsa.pub # ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....
id_rsa.pub是公鑰。文件中的內容就是公鑰。
五、把公鑰添加到github或oschina
在公鑰的位置,複製上id_rsa.pub文件的內容。
六、驗證oschina的公鑰是否設置成功(這一步可忽略)
添加後,在終端(Terminal)中輸入
ssh -T git@git.oschina.net
若返回
Welcome to Git@OSC, yourname!