我是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
请帮助。
答案 0 :(得分:0)
我尝试做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