# Source Tree 用 ssh 連線 ## 方法一 - 上方工具列 tools -> create or import ssh keys ![](https://i.imgur.com/T8dK3q2.png) - 按 Generate (Type 是 RSA) ![](https://i.imgur.com/SWNCw6N.png) - 按 Save private key - 到 github -> settings -> ssh and GPG keys -> new ssh key 將 public key 貼上 ![](https://i.imgur.com/7Wg9ey4.png) ![](https://i.imgur.com/GUdvydA.png) - putty 按右鍵 add key -> 選擇 剛剛儲存的 private key ![](https://i.imgur.com/DPlAojz.png) ## 方法二 - ssh-keygen -t rsa -b 4096 -C 'example@demo.com' 會產生 public 和 private key - 設定 .ssh/config (C:\Users\your_username\.ssh) ``` Host github.com HostName github.com PreferredAuthentications publickey IdentityFile /Users/example/.ssh/example (剛剛產生的 filename) ``` - 打開 source tree -> Tools -> General -> SSH client Configuration -> ssh client 設定 openSSH 和 ssh key - 到 github -> settings -> ssh and GPG keys -> new ssh key 將 public key 貼上 檔案結尾是 `.pub` 沒有的是 private - 測試連線 ssh -T git@github.com ###### tags: `2021` `sourcetree` `git` `ssh` {%hackmd BJrTq20hE %}