Sourcetree 如何指定多把 SSH keys

Sourcetree 使用 SSH key 存取遠端儲存庫的好處多多 再也不用記一堆密碼或擔心密碼過期 但如果…

原先我會在一般設定裡指定 Private Key 絕對路徑

 

若有多把 SSH Keys 時有兩種方式可設定

1. 一樣指定 Private Key 目錄,不同 Private Key 間用分號區隔

 

2. 使用 Config 設定檔

在剛剛指定 Private Key 那個欄位留空
接著到 C:/Users/Username/.ssh 目錄下
建立一個檔名為 config 的檔案,不需任何副檔名

Sourcetree 預設就會來吃這個檔案
使用記事本來編輯檔案內容,內容範例如下

Host github.com
 Hostname github.com
 User github-user1
 IdentityFile D:sshKeygithub1.rsa

Host github.com
 Hostname github.com
 User github-user2
 IdentityFile D:sshKeygithub2.rsa

Host gitlab.com
 Hostname gitlab.com
 User gitlab-user
 IdentityFile D:sshKeygitlab.rsa  

以上範例是設定兩組 Github 帳號以及一組 Gitlab 帳號

  • Host 與 Hostname 基本一致
  • User 為您在該平台的帳號
  • IdentityFile 則指定私鑰檔路徑檔名

設定完後即可透過 SSH key 存取
與方法一相比較為麻煩,但能比較清楚哪一把 KEY 是哪一個平台帳號專用
以上簡單紀錄

11 則留言

  1. Excellent guide on managing multiple SSH keys! Proper key management is crucial for maintaining secure development workflows. Just as we prioritize encrypted secure platforms and user data protection at nino gaming ph club, developers must implement robust security practices. The SSH config method offers superior organization and scalability for teams managing multiple repositories.

  2. Excellent guide on managing multiple SSH keys! Proper key organization is crucial for development workflows, especially when juggling various Git accounts across different platforms. Just as secure authentication matters in development, reliable access management ensures smooth operations. Much like how jiliee slot platforms prioritize secure user access, SSH key management protects your code repositories effectively.

  3. Just finished my weekend web hunt and stumbled on this gem. The color prediction mechanics at philwin app feel surprisingly intuitive for quick sessions. Secure deposits via GCash make it a top pick for Filipino gamers seeking fast-paced entertainment and real money wins without the usual hassle of lengthy verification processes or slow bank transfers that plague other platforms in the region today.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *