何時會使用SSH Key
- 使用ssh連線時
- 不想輸入帳密時
- 檔案太大時
如何使用SSH Key
1. 建立SSH Key
1.1 先查看GitLab裡的教學

點選 generate it 出現如下畫面

1.2 開啟Git Bash

1.3 輸入1.1裡看到的指令ssh-keygen -t rsa -C "your email"

依指示輸入檔案產生的位置及密碼, 若不變更, 一直按Enter即可
紅框標示即檔案位置
2. 建立Putty Key
2.1 開啟Puttygen

2.2 載入剛剛產生的private key

檔案類型選擇All Files(*.*)

2.3 儲存剛載入的key, 將其副檔名存為.ppk

3. 使用SSH來連線
3.1 在TortoiseGit設定SSH連線

URL設定xxx@gitlab.servername:ooo.git
Putty Key載入剛存的.ppk
3.2 在GitLab設定SSH Key
即第1張圖例, 點選Add SSH Key後
Title可任意取名
Key則是把1.3產生的.pub內容(用記事本開就能看到內容)copy/paste過來即可