在github / bitbucket上使用多个帐户/多重身份推送 [英] push using multiple account / multiple identity on github / bitbucket

查看:160
本文介绍了在github / bitbucket上使用多个帐户/多重身份推送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在github / bitbucket上有多个帐户,每个帐户有一个唯一的私钥 - 公钥对。当我需要推送到由不同帐户创建的回购站时,问题就会发生,除非我推入默认帐户(我最初创建的帐户),否则几乎肯定会拒绝访问。

I have multiple accounts on github / bitbucket and one unique private-public key pair for each account. The problem occurs when I need to push to the repos created by the different accounts, I will almost certainly get access denied unless I am pushing into the default account (the account that I first created).

有没有办法在推送之前切换到不同的凭据?我在Macintosh机器上使用源码树。我不希望在需要推送时手动重命名〜/ .ssh / id_rsa

Is there a way to switch to different credentials before pushing? I am using Source Tree on Macintosh machine. I'd prefer not to rename ~/.ssh/id_rsa manually whenever I need to push.

谢谢非常适合您的输入!

Thank you very much for your input!

推荐答案

您可以使用〜/ .ssh / config 解释如下:

https://confluence.atlassian.com/pages/viewpage.action?pageId=271943168

Host workdid
 HostName bitbucket.org
 IdentityFile ~/.ssh/workdid
Host personalid
 HostName bitbucket.org
 IdentityFile ~/.ssh/personalid

否则,如果您只是想在推送前切换帐户,则可以使用 SSH-添加。打开 Terminal.app ,运行 ssh-agent 并运行 ssh-add〜/。 ssh / path_to_your_account_id_rsa ,然后进行推送。
推后,您可以运行以下命令切换回默认账户: ssh-add〜/ .ssh / id_rsa

Otherwise, if you just want to "switch account" before doing the pushing, you can use ssh-add. Open the Terminal.app, run ssh-agent and run ssh-add ~/.ssh/path_to_your_account_id_rsa, then do the push. After pushing, you can switch back to your default account by running: ssh-add ~/.ssh/id_rsa.

希望它有帮助!

这篇关于在github / bitbucket上使用多个帐户/多重身份推送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆