Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用GIT trought SSH连接Amazon EC2时权限被拒绝_Git_Amazon Web Services_Ssh_Amazon Ec2_Bitbucket - Fatal编程技术网

使用GIT trought SSH连接Amazon EC2时权限被拒绝

使用GIT trought SSH连接Amazon EC2时权限被拒绝,git,amazon-web-services,ssh,amazon-ec2,bitbucket,Git,Amazon Web Services,Ssh,Amazon Ec2,Bitbucket,我使用AmazonEC2实例作为开发服务器,并尝试将我的存储库从bitbucket git克隆到AmazonEC2实例。我喜欢做的是将post hook commit添加到bitbucket,这样所有提交到存储库的更改都会自动反映到我的开发服务器上 我正在通过ssh连接到我的Amazon EC2实例,但当我尝试git克隆存储库时,我遇到以下错误: Permission denied (publickey). fatal: Could not read from remote repository

我使用AmazonEC2实例作为开发服务器,并尝试将我的存储库从bitbucket git克隆到AmazonEC2实例。我喜欢做的是将post hook commit添加到bitbucket,这样所有提交到存储库的更改都会自动反映到我的开发服务器上

我正在通过ssh连接到我的Amazon EC2实例,但当我尝试git克隆存储库时,我遇到以下错误:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我找到了很多解决这个问题的方法,但似乎没有一个有效

以下是我迄今为止所尝试的:

-创建弹性ip并与我的实例关联

-已修改安全组以允许入站网络流量

-从amazon下载生成的pem密钥,并使用puttygen生成私钥和公钥

-已将公钥(id_rsa.pub)和pem密钥上载到my.ssh文件夹,并将权限更改为600

-将公钥添加到bitbucket部署密钥

-将公钥添加到amazon上的授权密钥文件中

-在.ssh文件夹中创建了一个配置文件,并在其中添加了以下行:

Host bitbucket.org
Hostname bitbucket.org
User ubuntu
IdentityFile ~/.ssh/amzon_key.pem
-试图以root用户身份对存储库进行git克隆

我正在windows上使用腻子。

解决方案由OP提供

我做了什么使它工作:

-已从.ssh文件夹中删除配置文件

-使用puttygen(dsa-1024)创建新的私钥和公钥

-将公钥添加到bitbucket部署密钥

-将公钥添加到.ssh文件夹中的amazon authorized_keys文件中

-已将密钥上载到.ssh文件夹,并将权限设置为600


-将bitbucket.org添加到.ssh文件夹中的已知主机文件列表中

我们需要在此处添加的密钥就是我们在bitbucket中添加的密钥。因此服务器有权访问bitbucket并执行git命令。因此,请使用您添加的名称更改标识文件名。如问题所述,它是id_rsa

Host bitbucket.org
Hostname bitbucket.org
User ubuntu
IdentityFile ~/.ssh/id_rsa
这是一个建议。因为我没有足够的声誉来评论