設定 github 帳號的 git ssh key

我們可以使用 git 的 https:// protocol 來透過 HTTP auth 來存取 github 的 git repos 外﹐也可以使用 git 的 ssh:// protocol 來存取 github。

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

$ ssh -t rsa -C “[email protected]”
$ ssh-add

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

$ ssh -T [email protected]
Hi sammyfung! You’ve successfully authenticated, but GitHub does not provide shell access.

這樣便成功了。

About Sammy Fung

Sammy Fung 是開放源碼倡導者,Python軟件基金會資深會員。他創辦開源香港、香港開源年會及 PyCon HK,曾任GNOME基金會董事。他在亞洲各城市籌辦過30場開源會議及開放數據黑客松。