簡體   English   中英

無法將項目從本地推送到AWS中設置的git存儲庫:權限被拒絕(公鑰)

[英]Unable to push project from local to git repository set up in AWS : Permission denied (publickey)

我是AWS的新手,並按照教程在AWS中設置git並將本地文件推送到其中。 我有一個帶有.pem擴展名的密鑰,該密鑰是在創建實例時生成的。 我已經這樣添加了遠程存儲庫: git remote add production ssh://root@35.154.37.131/var/repo/site.git

之后,當我嘗試推送到存儲庫時,我得到了:

 $ git push production master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我用谷歌搜索,但無法遵循解決方案。 但是,我可以使用以下命令SSH到實例:

ssh -i wexpert_instance_2.pem ubuntu@ec2-35-154-37-131.ap-south-1.compute.amazonaws.com

請幫忙。

我試着做git remote add production ssh://ubuntu@ec2-35-154-37-131.ap-south-1.compute.amazonaws.com/var/repos/site.git

這是預料之中的,因為默認情況下SSH將在~/.ssh/id_rsa查找您的密鑰。

由於沒有默認密鑰,因此需要使用以下命令定義〜/ .ssh / config文件(chmod 644):

Host myaws
Hostname ec2-35-154-37-131.ap-south-1.compute.amazonaws.com
User ubuntu
IdentityFile /full/path/to/wexpert_instance_2.pem

然后:

git remote set-url production myaws:/var/repo/site.git

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM