ssh配置多个bitbucket帐户 - 简单的例子,但'远端意外挂断' [英] ssh config for multiple bitbucket accounts - Simple example, but getting 'remote end hung up unexpectedly'

查看:215
本文介绍了ssh配置多个bitbucket帐户 - 简单的例子,但'远端意外挂断'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我的bitbucket用户名是jon,我有一些个人项目在 https://bitbucket.org/jon



假设我加入了一个名为devteam的开发小组,该开发小组可以在 https://bitbucket.org/devteam

然后假设我正在设置一台新机器。我生成了一个ssh密钥对, id_rsa id_rsa.pub ,它们位于〜/中。 SSH 。然后,我的开发团队负责人将我的 id_rsa.pub 公钥添加到bitbucket上的devteam帐户。现在我可以从devteam账户克隆项目并开始工作。



接下来我想与我自己的 jon id_rsa.pub 键添加到我的bitbucket帐户,因为bitbucket告诉我该密钥已被添加到帐户。这意味着我必须生成第二个密钥对。所以我按照这里的指示运行 ssh-keygen -f〜/ .ssh / jon -Cjonhttps://confluence.atlassian.com/pages/viewpage.action?pageId=271943168 然后添加这个 jon.pub 键到我的 jon 帐户在bitbucket。



现在我有两个密钥对, id_rsa jon ,我必须配置使用哪个键。按照上面链接的bitbucket帮助页面上的说明,我在〜/ .ssh 目录中创建一个 config 文件与以下内容:

 主机devteam 
HostName bitbucket.org
IdentityFile〜/ .ssh / id_rsa
Host jon
HostName bitbucket.org
IdentityFile〜/ .ssh / jon

然后通知我可以进行以下替换:从 git@bitbucket.org:jon / reponame.git git @ jon:jon / reponame.git



所以我尝试执行以下命令: git clone git @ jon: jon / reponame.git ,我得到以下错误:

 在/ home中初始化空的Git存储库/jon/dev/reponame/.git/ 
/home/jon/.ssh/config上的所有者或权限不正确
致命:远程端意外挂起


我做错了什么?



编辑:这里是我的的〜/ .ssh directory:

  [jon @ linuxmachine〜/ .ssh] 
1 $ ls - alh
总计32K
drwx ------。 2 jon 4.0K 1月18日19:20 ./
drwx ------。 11 jon 4.0K 1月18日19:34 ../
-rw-rw-r--。 1 jon 132 Jan 18 19:20 config
-rw -------。 1 jon 1.8K 1月18日15:21 id_rsa
-rw-r - r--。 1 jon 406 Jan 18 15:21 id_rsa.pub
-rw -------。 1 jon 1.7K 1月18日18:45 jon
-rw-r - r--。 1 jon 390 Jan 18 18:45 jon.pub
-rw-r - r--。 1 jon 808 Jan 18 18:40 known_hosts


解决方案

一样的问题。
在将文件〜/ .ssh / config 的权限更改为 -rw-r - r -
$ p $ /home/username/.ssh/config上的所有者或权限错误
致命错误:远端意外挂断

消失。

在控制台写入:

  cd〜/ .ssh 
chmod 644 config


Suppose my bitbucket user name is "jon" and I have some personal projects at https://bitbucket.org/jon.

Suppose I then join a development team that has a bitbucket account called "devteam" which can be found at https://bitbucket.org/devteam

Then suppose I am setting up a new machine. I generate an ssh key pair, id_rsa and id_rsa.pub which are in ~/.ssh. Then my dev team leader adds my id_rsa.pub public key to the devteam account on bitbucket. Now I can clone the projects from the devteam account and get to work.

Next I want to interact with my own jon account. However, I cannot add the id_rsa.pub key to my bitbucket account because bitbucket tells me that that key has already been added to an account. This means I have to generate a second key pair. So I run ssh-keygen -f ~/.ssh/jon -C "jon" as instructed here: https://confluence.atlassian.com/pages/viewpage.action?pageId=271943168 and then I add this jon.pub key to my jon account at bitbucket.

Now that I have two key pairs, id_rsa and jon, I have to configure which key gets used when. Following the instructions at the bitbucket help page linked to above, I create a config file in my ~/.ssh directory with the following contents:

Host devteam
 HostName bitbucket.org
 IdentityFile ~/.ssh/id_rsa
Host jon
 HostName bitbucket.org
 IdentityFile ~/.ssh/jon

I am then informed that I can make the following substitution: From git@bitbucket.org:jon/reponame.git to git@jon:jon/reponame.git

So I try to execute the following command: git clone git@jon:jon/reponame.git and I get the following error:

Initialized empty Git repository in /home/jon/dev/reponame/.git/
Bad owner or permissions on /home/jon/.ssh/config
fatal: The remote end hung up unexpectedly

What did I do wrong?

Edit: Here are the file permissions in my ~/.ssh directory:

[jon@linuxmachine ~/.ssh]
 1$ ls -alh
total 32K
drwx------.  2 jon 4.0K Jan 18 19:20 ./
drwx------. 11 jon 4.0K Jan 18 19:34 ../
-rw-rw-r--.  1 jon  132 Jan 18 19:20 config
-rw-------.  1 jon 1.8K Jan 18 15:21 id_rsa
-rw-r--r--.  1 jon  406 Jan 18 15:21 id_rsa.pub
-rw-------.  1 jon 1.7K Jan 18 18:45 jon
-rw-r--r--.  1 jon  390 Jan 18 18:45 jon.pub
-rw-r--r--.  1 jon  808 Jan 18 18:40 known_hosts

解决方案

I had the same problem. After i changed permissions of the file ~/.ssh/config to -rw-r--r--, the error

Bad owner or permissions on /home/username/.ssh/config
fatal: The remote end hung up unexpectedly

disappeared.

Write in console:

cd ~/.ssh
chmod 644 config

这篇关于ssh配置多个bitbucket帐户 - 简单的例子,但'远端意外挂断'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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