权限被拒绝(公钥)推动承诺的Amazon EC2时 [英] Permission denied (publickey) when pushing commit to amazon ec2

查看:705
本文介绍了权限被拒绝(公钥)推动承诺的Amazon EC2时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,有很多类似的问题存在,在这里(和我发布这个之前看了很多他们的),但是这一次是不同的,所以请留在我身边了一会儿。

我前几天配置在Amazon EC2上我的远程git仓库。经过苦苦挣扎的时间我做了它的工作,并能有文件。我正与它一两天,推动资源,它没有任何问题(我看到每次更新正确的)。

今天,由于某种原因,我无法把它从我的本地机器推什么。

混帐推部署结束与以下错误消息(同一个我看到的时候我试图获取有关部署的信息:远程Git秀部署):

 警告:push.default没有设置;其隐含的价值正在改变
Git的2.0从匹配到简单。为了压制此消息
并保持后的默认改变目前的行为,请使用:

  混帐配置--global push.default匹配

为了压制这个消息,现在采用新的行为,请使用:

  混帐配置--global push.default简单

见'混帐帮助配置,然后搜索push.default以获取更多信息。
(在简单模式被引入的Git 1.7.11,使用类似的模式
当前的',而不是'简单',如果你有时会使用旧版本的Git)
 

 权限被拒绝(公钥)。
致命的:无法从远程存储库中读取。
请确保您有正确的访问权限
和库中存在。
 

它的第一部分(拒绝授权前)我能看到previously,但它仍然是推动一切正常当时的情况。

部署存在的,因为我可以清楚地看到它与远程Git -v

 部署SSH:// Ubuntu的@ XXXX /家庭/ Ubuntu的/回购(取)
配置SSH:// Ubuntu的@ XXXX /家庭/ Ubuntu的/回购(推)
 

我可以正确ssh到我的服务器,也是我的私钥 0400 的权限。在两台机器上我有的Ubuntu 12.04 LTS

我觉得可能是有一些问题,我的公钥,所以我说干就干,从私钥创建它:的ssh-凯基-y -f key.pem> key.pub 。根据其 SHA 它等同于我的previous公钥: SHA1SUM KEY_ prev.pub = SHA1SUM key.pub

我还是去了服务器,并增加了一个新的密钥来授权密钥为好。

仍然没有改变。我不能把任何东西。谁能告诉我什么是这里的问题和为什么会发生?我需要跟做任何我的地方的.ssh / known_hosts里面

此外,在其中一个答案,我发现了以下内容:

  

请注意,重新启动实例后,DNS名称变更。   我爱上了几次。密钥文件仍然有效,但   服务器名称变了。

其实,我重新启动我的机器,所以我觉得这是高度相关的。问题是,我不明白我现在应该改变。

看完VonC的答案。

我不能这样做 SSH Ubuntu的@ XXXX (我得到了权限被拒绝(公钥)。),但我可以用 SSH myAlias​​ ,其中myAlias​​在的〜/ .ssh /配置 <定义/ P>

 主机myAlias
主机名X.X.X.X
用户的Ubuntu
IdentityFile路径/要/ mypem / file.pem
 

当我做了混帐配置--global push.default简单我还有一个问题,在做的时候混帐推部署

  

致命:当前分支主没有上游的分支。推   当前分支和远程设置的上游,用

     

混帐推--set上游部署主

我会尽量做到 SSH -Tvv Ubuntu的@ XXXX 并会告诉它如何去。

解决方案

首先,请你帮个忙,并键入混帐配置--global push.default简单为了不要看到错误的第一部分。

第二,如果你可以用 SSH Ubuntu的@ XXXX 登录成功,那么你的钥匙都很好,以及实例名称。

如果你不能,你可以:

  • 尝试一个 SSH -Tvv Ubuntu的@ XXXX 来看看是怎么回事之一,
  • 验证通过进入服务器,停止sshd的并重新启动在调试模式下( / usr / sbin目录/ sshd的-d ):它会收到只有一个SSH连接:尝试的ssh Ubuntu的@ XXXX从你的客户,你应该看到sshd的响应
    。 然后重新启动的sshd 正常。

在你的情况,你的有无的使用你的别名,在的〜/ .ssh /配置定义的,因为你的键不是标准之一。

有关推走畅,做一个混帐推-u部署主

由于 git的远程-v 返回:

 部署SSH:// Ubuntu的@ XXXX /家庭/ Ubuntu的/回购(取)
配置SSH:// Ubuntu的@ XXXX /家庭/ Ubuntu的/回购(推)
 

这意味着您不是使用ssh别名。

类型:

  git的远程设置URL部署myAlias​​:/家庭/ Ubuntu的/回购
 

(语法是很重要的: myAlias​​:后跟回购路径)

然后再次尝试混帐推

I know that a lot of similar questions exist here (and I read a lot of them before posting this one), but this one is different, so please stay with me for a while.

Few days ago I configured my remote git repository on amazon ec2. After hours of struggling I made it working and was able to push files there. I was working with it for a day or two pushing resources to it without any problems (I saw every update properly).

Today, for some reason I can not push anything to it from my local machine.

git push deploy ends up with the following error message (the same one I see when I try to get info about deploy: git remote show deploy):

warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

The first part of it (before permission denied) I was able to see previously, but it was still pushing everything correctly back then.

Deploy exist because I can clearly see it with git remote -v:

deploy  ssh://ubuntu@X.X.X.X/home/ubuntu/repo (fetch)
deploy  ssh://ubuntu@X.X.X.X/home/ubuntu/repo (push)

I can correctly ssh to my server, also my private key has 0400 permissions. On both machines I have ubuntu 12.04 LTS.

I thought that may be there is some problem with my public key, so I went ahead and recreate it from private key: ssh-keygen -y -f key.pem > key.pub. Based on its sha it is identical to my previous public key: sha1sum key_prev.pub = sha1sum key.pub

I still went to the server and added a new key to authorized keys as well.

Still no changes. I can not push anything. Can anyone tell me what is the problem here and why it happened? Do I need to do anything with my local .ssh/known_hosts?

Also in one of the answers I found the following:

Please note that after restarting the instance, the dns name changed. I fell for this several times. The keyfile was still valid, but the "servername" changed.

I actually restarted my machine, so I think this is highly relevant. The problem is that I can not understand what should I change now.

After reading the answer of VonC.

I can not ssh to the server by doing ssh ubuntu@X.X.X.X (I got Permission denied (publickey).), but I can do this with ssh myAlias, where myAlias is defined in ~/.ssh/config

Host            myAlias
Hostname        X.X.X.X
User            ubuntu
IdentityFile    path/to/mypem/file.pem

When I have done git config --global push.default simple I have another problem when doing git push deploy:

fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use

git push --set-upstream deploy master

I will try to do ssh -Tvv ubuntu@X.X.X.X and will tell how it goes.

解决方案

First, do yourself a favor, and type git config --global push.default simple in order to not see the first part of the error.

Second, if you can login successfully with ssh ubuntu@X.X.X.X, then your keys are fine, as well as the instance name.

If you can not, you can:

  • try a ssh -Tvv ubuntu@X.X.X.X to see what is going one, and
  • verify that by going to the server, stopping sshd and restarting it in debug mode (/usr/sbin/sshd -d): it will receive only one ssh connection: try a ssh ubuntu@X.X.X.X from your client, and you should see the sshd response.
    Then restart sshd normally.

In your case, you have to use your alias, defined in ~/.ssh/config, since your key isn't a standard one.

For the push to go smoothly, do a git push -u deploy master.

Since git remote -v returns:

deploy  ssh://ubuntu@X.X.X.X/home/ubuntu/repo (fetch)
deploy  ssh://ubuntu@X.X.X.X/home/ubuntu/repo (push)

That means you are not using the ssh alias.

Type:

git remote set-url deploy myAlias:/home/ubuntu/repo

(The syntax is important: myAlias: followed by the repo path)

And then try again the git push.

这篇关于权限被拒绝(公钥)推动承诺的Amazon EC2时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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