一 . github上創建立一個項目
用戶登錄后系統,在github首頁,點擊頁面右下角“New Repository”
填寫項目信息:
project name: hibernate-demo
description : my first project
點擊“Create Repository” ; 現在完成了一個項目在github上的創建。
二 . 創建密鑰
(1).配置用戶名和郵箱(如果已經配置,就跳過)
git config –global user.name ‘xxxxx’
git config –global user.email ‘xxx@xx.xxx’
(2).檢查下自己之前有沒有已經生成shh
cd ~/.ssh
如果能進入到.ssh文件目錄下 ,則證明,之前生成過.ssh秘鑰,可以直接使用里面的秘鑰。
(3).生成秘鑰
ssh-keygen -t rsa -C ‘xxx@xx.xxx’ //配置的郵箱
接着按3個回車 :
1 Generating public/private rsa key pair.
2 Enter file in which to save the key (/c/Users/Mr.Yang/.ssh/id_rsa): 3 Enter passphrase (empty for no passphrase): 4 Enter same passphrase again: 5 Your identification has been saved in /c/Users/Mr.Yang/.ssh/id_rsa. 6 Your public key has been saved in /c/Users/Mr.Yang/.ssh/id_rsa.pub. 7 The key fingerprint is: 8 SHA256:zA6wNJrFB6NcqS6eBog/AHlzQuvFjYpG759Yhh1lWGI xxxxxx@xxxxx.xxx(上面自己的郵箱) 9 The key's randomart image is: 10 +---[RSA 2048]----+ 11 | +E . | 12 | ..+oo+ | 13 | oo+*+.o | 14 |o.*===+o | 15 |==+*... S | 16 |B.+.o .o | 17 |++o. + . | 18 | +o.+ . | 19 |. o.o | 20 +----[SHA256]-----+
最后在.ssh目錄下得到了兩個文件:id_rsa(私有密鑰)和id_rsa.pub(公有密鑰)
三 . 將公有密鑰添加到github SSH keys
使用記事本等軟件打開id_rsa.pub文件,將里面的內容復制,粘貼到github的New SSH key
四 .驗證是否連接成功
$ ssh git@github.com