---
title: "設定 github 帳號的 git ssh key"
url: https://sammy.hk/%e8%a8%ad%e5%ae%9a-github-%e5%b8%b3%e8%99%9f%e7%9a%84-git-ssh-key/
author: Sammy Fung
published: 2012-09-17T22:09:07+08:00
modified: 2018-03-21T22:23:22+08:00
description: "我們可以使用 git 的 https:// protocol 來透過 HTTP auth 來存取 github 的 git repos 外﹐也可以使用 git 的 ssh:// protocol 來存取 github。 先在 command line，使用 ssh command 來產生和加入自己的 ssh key (…"
categories: ["開放源碼"]
tags: ["開放源碼"]
source: https://sammy.hk
---
我們可以使用 git 的 https:// protocol 來透過 HTTP auth 來存取 github 的 git repos 外﹐也可以使用 git 的 ssh:// protocol 來存取 github。

先在 command line，使用 ssh command 來產生和加入自己的 ssh key (RSA v2)。

$ ssh -t rsa -C “example@sammy.hk”
$ ssh-add

然後登入 github.com，在 Account Setting 的 SSH Keys 加入自己的 SSH Keys (Add SSH Keys)，再把 ~/.ssh/id\_rsa.pub 的內容貼在 Key 的一欄內﹐完成後進行一次測試。

$ ssh -T git@github.com
Hi sammyfung! You’ve successfully authenticated, but GitHub does not provide shell access.

這樣便成功了。

### 相關文章：

1. [開放源碼香港天氣計劃 hk0weather](https://sammy.hk/opensource-hk0weather/ "開放源碼香港天氣計劃 hk0weather")
2. [自製港鐵即時班次資料一頁過](https://sammy.hk/%e8%87%aa%e8%a3%bd%e6%b8%af%e9%90%b5%e5%8d%b3%e6%99%82%e7%8f%ad%e6%ac%a1%e8%b3%87%e6%96%99%e4%b8%80%e9%a0%81%e9%81%8e/ "自製港鐵即時班次資料一頁過")
3. [參與開放源碼本應的模式](https://sammy.hk/%e5%8f%83%e8%88%87%e9%96%8b%e6%94%be%e6%ba%90%e7%a2%bc%e6%9c%ac%e6%87%89%e7%9a%84%e6%a8%a1%e5%bc%8f/ "參與開放源碼本應的模式")
4. [Hacktoberfest 2020](https://sammy.hk/hacktoberfest-2020/ "Hacktoberfest 2020")
