我知道這裏存在很多類似的問題(在發佈這個問題之前我讀了很多類似的問題),但這一個是不同的,所以請留在我身邊一會兒。當推送提交給亞馬遜ec2時,權限被拒絕(publickey)
幾天前我在亞馬遜ec2上配置了我的遠程git倉庫。經過幾個小時的努力,我使它工作,並能夠在那裏push
文件。我一直在使用它一兩天,沒有任何問題推動資源(我正確地看到每一個更新)。
今天,出於某種原因,我無法從我的本地機器上推送任何東西。
git push 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.
它的第一部分(在拒絕權限之前)我之前可以看到,但它仍然在正確地推動所有事情。
部署存在,因爲我可以清楚地看到git remote -v
它:
deploy ssh://[email protected]/home/ubuntu/repo (fetch)
deploy ssh://[email protected]/home/ubuntu/repo (push)
我可以正確地SSH到我的服務器,也是我的私鑰0400
權限。在兩臺機器上我都有ubuntu 12.04 LTS
。
我認爲可能是我的公鑰存在一些問題,所以我繼續從私鑰重新創建它:ssh-keygen -y -f key.pem > key.pub
。基於它的sha
它與我以前的公鑰相同:sha1sum key_prev.pub
= sha1sum key.pub
我還是去了服務器併爲授權密鑰添加了新密鑰。
仍然沒有變化。我無法推動任何東西。誰能告訴我這裏有什麼問題,爲什麼會發生?我需要用我的當地.ssh/known_hosts
做什麼嗎?
此外,在其中一個答案,我發現以下幾點:
請注意,重新啓動實例後,DNS名稱變更。 我倒了好幾次。密鑰文件仍然有效,但 「服務器名稱」已更改。
我真的重新啓動我的機器,所以我認爲這是高度相關的。問題是我不明白我現在應該改變什麼。
在閱讀VonC的答案後。
我不能做ssh [email protected]
(我Permission denied (publickey).
)ssh登錄到服務器上,但我可以ssh myAlias
,其中myAlias在~/.ssh/config
Host myAlias
Hostname X.X.X.X
User ubuntu
IdentityFile path/to/mypem/file.pem
定義做到這一點。當我做了git config --global push.default simple
我有另一個問題:git push deploy
:
fatal:當前分支主機沒有上游分支。推 當前分支和設置遠程上游,使用
混帳推--set上游部署主
我會盡量做到ssh -Tvv [email protected]
,並會告訴它如何去。
當你在''/ var/log/auth.log'上得到'Permission denied'日誌時,你的實例是什麼? – clement
@ clement89這裏是尾部的輸出。 '時間戳用戶名CRON [31495]:pam_unix(cron:session):通過(uid = 0)爲用戶根打開的會話 時間戳用戶名CRON [31495]:pam_unix(cron:session):session for closed root'。 –