简体   繁体   English

bitbucket为第二台机器设置ssh

[英]bitbucket setting up ssh for a 2nd machine

Sometimes ago I got this issue and tried to follow the instruction for my PC. 有时以前我遇到了这个问题,并尝试按照PC上的说明进行操作。

Cannot push to git repository on bitbucket 无法推送到Bitbucket上的git存储库

It worked, and I already have one SSH key with bitbucket. 它起作用了,我已经有了一个带bitbucket的SSH密钥。

Now I have another machine with a new hard drive, so I need to setup git again. 现在,我有一台装有新硬盘的机器,因此我需要再次设置git。 I thought I could just add the global config: 我以为我可以添加全局配置:

git config --global user.name '<myname>'
git config --global user.email '<myemail>'

But it doesn't work. 但这是行不通的。 So it seems like I need to go through the steps mentioned in the above link all over again. 因此,似乎我需要再次遍历以上链接中提到的步骤。

Is there a better way to setup that SSH access from an existing account (jsut from a differ machine) rather than following such a long and mundane steps. 有没有更好的方法来设置从现有帐户(来自其他计算机的jsut)的SSH访问权限,而不是执行冗长而繁琐的步骤。

Now I have another machine with a new hard drive, so I need to setup git again. 现在,我有一台装有新硬盘的机器,因此我需要再次设置git。 I thought I could just add the global config: 我以为我可以添加全局配置:

 git config --global user.name '<myname>' git config --global user.email '<myemail>' 

But it doesn't work. 但这是行不通的。

That's right. 那就对了。 It would be a shame if somebody else could just run those commands and gain access to your account! 如果其他人可以只运行这些命令并获得对您帐户的访问权限,那将是可耻的!

Those settings are actually irrelevant to Git authentication. 这些设置实际上与Git身份验证无关。 They just determine how commits are recorded. 他们只是确定如何记录提交。

So it seems like I need to go through the steps mentioned in the above link all over again. 因此,似乎我需要再次遍历以上链接中提到的步骤。

That's what I'd recommend: Generate a keypair for your new machine and add it to your Bitbucket account. 那就是我的建议:为您的新计算机生成一个密钥对,并将其添加到您的Bitbucket帐户。

(Technically you could avoid creating a new keypair if you copy your existing keypair from your old machine onto your new one, but that's trickier than it sounds. OpenSSH is very picky about file permissions. I always create new keypairs per machine.) (从技术上讲,如果将现有密钥对从旧计算机复制到新计算机上,则可以避免创建新的密钥对,但这听起来并不那么棘手。OpenSSH对文件权限非常挑剔。我总是为每台计算机创建新的密钥对。)

Finally, you could access your repositories via HTTPS instead of SSH. 最后,您可以通过HTTPS而非SSH访问存储库。 That way you'd have to enter your Bitbucket user name and password to gain access. 这样,您必须输入Bitbucket用户名和密码才能访问。 Though if you've enabled two-factor authentication that gets trickier… 不过,如果您启用了两因素身份验证会变得更加棘手……

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM