畑乃おいも / Hatano Oimo
468 字
2 分鐘
github ssh設定
介紹
github 使用 SSH 連線可以上傳 Private(私人)儲存庫,暫時還不想開放給人觀看 code 或是公司專案非常適合使用 SSH 連線來上傳檔案,依照 github 官方文檔介紹設定。
推薦教學觀看頻道
github 官方文檔
安裝需求
必須安裝:git git-scm.com(在新分頁開啟)
設定方法
開啟 Git Bash 程式
輸入 將 email 改成 你的 github 的 email
會看到此訊息
使用提供的電子郵件作為標籤,將建立一個新的 ssh key。
> Generating public/private rsa key pair.按下鍵盤的 Enter
Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]輸入 y
/c/Users/you/.ssh/id_rsa already exists.Overwrite (y/n)? y輸入短密碼 方便記憶可與 github 密碼相同
Enter passphrase (empty for no passphrase):Enter same passphrase again:產生的 key 檔案路徑,依你的路徑為主,稍後需要 id_rsa.pub 檔案內的 key 複製到 github

設定 SSH KEY

選擇SSH and GPG keys.

選擇 New SSH key

使用記事本打開 id_rsa.pub 將裡面的 key 複製到裡面,Title 可隨便取

點選

確認,登入密碼

SSH key 加入到 ssh-agent
eval $(ssh-agent -s)SSH 私鑰添加到 ssh-agent
ssh-add ~/.ssh/id_rsa確認是否連線成功
開啟 Git Bash 程式
顯示 代表成功
plain > Hi username! You’ve successfully authenticated, but GitHub does not > provide shell access.
push code 到 github
如果是建立全新的儲存庫,需要輸入 git init。
plain git init
// "." 代表上傳當前路徑的全部資料git add .
git commit -m "first commit"
git remote add origin [email protected]:you/you.git
git push -u origin master
// 會要求輸入短密碼Warning: Permanently added the RSA host key for IP address 'xx.xx.xx.x' to the list of known hosts.Enter passphrase for key '/c/Users/you/.ssh/id_rsa':]如果遇到問題或是想看更多詳細教學請到 github 官方文檔
https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh(在新分頁開啟)
