无法在EC2 Ubuntu实例中使用git ssh连接到bitbucket

我正在尝试在ubuntu EC2实例上使用SSH连接git。

我尝试了以下步骤,但出现公钥错误。

  • 使用命令 ssh-keygen 生成SSH,并将该密钥添加到bitbucket中。
  • 编辑〜username / .ssh / authorized_keys并添加生成的密钥。
  • 当我运行命令 ssh -T git@bitbucket.org 时,我看到以下结果

    logged in as user-name
    
    You can use git or hg to connect to Bitbucket. Shell access is disabled
    
  • 如果我在项目目录中执行git pull,则出现错误

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

帮我摆脱这个错误。

注意:我尝试了以下解决方案,但没有用。 git push origin master: permission denied (public key) error

注意(已更新)::它可以在具有SSH密钥的本地计算机(windows)中使用。

bmlun 回答:无法在EC2 Ubuntu实例中使用git ssh连接到bitbucket

您可能需要更改密钥和文件夹的权限。

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

您可能还需要更改主目录的权限,并删除该组和其他用户的写访问权限。

chmod go-w ~

This帮助我回答了您的问题。

,

我尝试了以下解决方案,效果很好。

sudo su - root  # switch to root user
cat ~/.ssh/id_rsa.pub  # create if not already existing
sudo su - ubuntu  # switch back to normal user

此引用来自Unable to add ssh-key of EC2 instance to bitbucket account

本文链接:https://www.f2er.com/3136353.html

大家都在问