日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

一台电脑同时配置github私人账户和公司账户

發布時間:2023/12/8 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 一台电脑同时配置github私人账户和公司账户 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

參考:

https://www.cnblogs.com/xjnotxj/p/5845574.html

http://blog.csdn.net/birdben/article/details/51824788

https://help.github.com/articles/error-permission-denied-publickey/

######################################

1. 兩個賬戶分別生成ssh key

cd ~/.ssh

ssh-keygen -t rsa -C "2453929471@qq.com"

這個文件我叫它: id_rsa_self, 同時會生成一個id_rsa_self.pub

ssh-keygen -t rsa -C "mgao@company.com"

這個文件我叫它: id_rsa_company, 同時會生成一個id_rsa_company.pub


2. 添加私鑰

ssh-agent -s ssh-add ~/.ssh/id_rsa_self ssh-add ~/.ssh/id_rsa_company


3. 分別登錄私人和公司的github,配置ssh-key

將 id_rsa_xxx.pub的內容貼進去



4. 配置 config

cd ~/.ssh

touch config

# self(2453929471@qq.com)

Host github.com

HostName github.com

PreferredAuthentications publickey

IdentityFile ~/.ssh/id_rsa_self

User 2453929471


# company(mgao@company.com)

Host github.company.com

HostName github.com

PreferredAuthentications publickey

IdentityFile ~/.ssh/id_rsa_company

User mgao


5. 測試

?? .ssh ssh -T git@github.company.com

Hi mgao! You've successfully authenticated, but GitHub does not provide shell access.

?? .ssh ssh -T git@github.com ? ? ? ? ? ? ?

Hi 2453929471! You've successfully authenticated, but GitHub does not provide shell access.


注意,我當時這里犯了一個錯誤,就是我用的 mgao@github.company.com去登錄的,然后報publickey的錯誤。

官方文檔寫的很清楚

Always use the "git" user

All connections, including those for remote URLs, must be made as the "git" user. If you try to connect with your GitHub username, it will fail:

ssh -T GITHUB-USERNAME@github.com Permission denied (publickey).

If your connection failed and you're using a remote URL with your GitHub username, you can?change the remote URL to use the "git" user.

You should verify your connection by typing:

ssh -T git@github.com Hi username! You've successfully authenticated...



總結

以上是生活随笔為你收集整理的一台电脑同时配置github私人账户和公司账户的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。