简体   繁体   English

如何在Mac OSX上使用Mercurial和Bitbucket设置SSH?

[英]How to setup SSH with Mercurial and Bitbucket on Mac OSX?

I cannot find a simple step-by-step guide to setup an OSX machine with Bitbucket and SSH. 我找不到简单的分步指南来使用Bitbucket和SSH设置OSX计算机。

So it requires me to google for different pages (to create SSH keys and to set them up in Bitbucket) whenever I'm setting up a new machine. 因此,每当我设置一台新机器时,它都需要我在Google上搜索不同的页面(以创建SSH密钥并在Bitbucket中进行设置)。 It seems valuable to have one complete list available in StackOverflow. 在StackOverflow中提供一个完整的列表似乎很有价值。

It's actually pretty straightforward. 实际上非常简单。

Check if you have a public key already that you could reuse: 检查您是否已经拥有可以重复使用的公钥:

ls -a ~/.ssh

If there is NO public key file id_rsa.pub then generate one: 如果没有公共密钥文件id_rsa.pub则生成一个:

ssh-keygen

Accept defaults. 接受默认值。 I don't enter password because I prefer to keep my hard drive encrypted whenever the repository contents are critical. 我不输入密码,因为只要存储库内容很重要,我都希望对硬盘进行加密。

Copy your public key to clipboard: 将您的公钥复制到剪贴板:

pbcopy < ~/.ssh/id_rsa.pub

Let Bitbucket know the identity of your computer: 让Bitbucket知道您的计算机的身份:

  • Go to https://bitbucket.org 前往https://bitbucket.org
  • Open your account settings under your avatar 在头像下打开您的帐户设置
  • Find "SSH keys" and choose to add a new one 找到“ SSH密钥”,然后选择添加一个新的
  • Paste your public key from pbcopy pbcopy粘贴您的公钥

Clone (pull, push or whatever) your repository using SSH: 使用SSH克隆(拉,推或其他方式)您的存储库:

hg clone ssh://hg@bitbucket.org/<username>/<repository>

First time you will get a warning similar to this: 第一次,您将收到类似以下警告:

The authenticity of host 'bitbucket.org (104.192.143.1)' can't be established.
RSA key fingerprint is 97:...:40.

You should google for "Bitbucket fingerprint" and compare what you see in terminal with what Atlassian documentation gives because fingerprints could change and can be faked. 您应该在Google上搜索“ Bitbucket指纹”,并将在终端中看到的内容与Atlassian文档提供的内容进行比较,因为指纹可能会更改并且可能会被伪造。

Have fun! 玩得开心!

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

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