--- tags: 隨手筆記 --- # About Github contributed by < `tl32rodan` > ## SSH setting: * Question: * 在 push/pull 時, 總是要輸入使用者帳號密碼 * `git clone git://...` 的 repositories 沒辦法更新 * 在 [github setting 中加入 ssh keys](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh) 後, 輸入 `ssh -T git@github.com` 仍然沒反應 * Solving process: * 先嘗試過重新加入 ssh keys 到 github setting, 但仍然無用 * 發現之前設定 ssh server 時[改過 port 22 為其他](http://linux.vbird.org/linux_server/0310telnetssh.php#ssh_port), 所以 把 port 22 新增回來並執行 `service ssh restart` * 結果:仍然無效 * 最後參考了[這篇 github 官方文件](https://docs.github.com/en/github/authenticating-to-github/using-ssh-over-the-https-port), 才成功解決 * 步驟說明: * *Step 1*: 測試 ssh over HTTPS port 可行 * 執行 `$ ssh -T -p 443 git@ssh.github.com` * 若跳出以下 message 則代表可以~ > Hi username! You've successfully authenticated, but GitHub does > not provide shell access. * 如果不行, 請參考[Trouble Shooting Guide](https://docs.github.com/en/articles/error-permission-denied-publickey) * *Step 2*: 啟用 SSH 連線 over HTTPS * 文件原話是這麼說的: > If you are able to SSH into git@ssh.github.com over port 443, you can override your SSH settings to force any connection to GitHub to run though that server and port. * 總之上面 *step 1* 如果可以執行, 就可以繼續 * 執行 `$ touch ~/.ssh/config` 並以你習慣的編輯器打開 `~/.ssh/config` , 再貼上: ``` Host github.com Hostname ssh.github.com Port 443 ``` * 再一次測試 `$ ssh -T git@github.com` * 結果應該如下: > Hi username! You've successfully authenticated, but GitHub does > not provide shell access. :::success 另外, 也可以參考使[用 https 來 clone 並暫存使用者名稱](https://docs.github.com/en/github/using-git/caching-your-github-credentials-in-git)的說明 :::