【问题标题】:push to remote git repository on ubuntu server - Permission denied (publickey)推送到 ubuntu 服务器上的远程 git 存储库 - 权限被拒绝(公钥)
【发布时间】:2018-01-13 14:22:37
【问题描述】:

我在 Windows 机器上尝试将代码推送到运行 ubuntu 的 ec2 实例上的远程 git 存储库。我已经设置了实例并在实例的某个位置创建了一个裸仓库。

我在实例上有我的公钥,因为我可以通过 putty 和我安装的 openssh 软件 ssh 到它。

我签了

https://serverfault.com/questions/39733/why-do-i-get-permission-denied-publickey-when-trying-to-ssh-from-local-ubunt

git push heroku master Permission denied (publickey)

Git - Permission denied (publickey)

但建议的解决方案对我来说不是很清楚

我可以使用 ssh -i mykey.pem ubuntu@1.1.1.1 SSH 进入实例。

问题是我已将 repo 添加到我的遥控器列表中,但是当我尝试使用从本地 master 推送到远程 repo 时,我不断收到以下错误

production - ssh://ubuntu@ec2-1-1-1-1.compute-1.amazonaws.com

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.

【问题讨论】:

    标签: git ubuntu github amazon-ec2 ssh


    【解决方案1】:

    我可以使用 ssh -i mykey.pem ubuntu@1.1.1.1 SSH 进入实例。

    这就是问题所在——你使用 mykey.pem 进行 ssh 但 git 使用默认密钥。您必须配置 ssh 以便 mykey.pem 是该主机的默认密钥:

    # .ssh/config
    Host ec2-1-1-1-1.compute-1.amazonaws.com
       User ubuntu
       IdentityFile mykey.pem
    

    【讨论】:

    • 它似乎改变了连接中的某些内容,但我现在在尝试推送时遇到此错误 -- 致命:协议错误:坏行长度字符:Agen 致命:远程端意外挂断跨度>
    猜你喜欢
    • 2013-02-28
    • 2014-02-01
    • 1970-01-01
    • 2017-12-18
    • 2012-11-20
    • 2016-02-21
    • 2021-03-04
    • 2016-02-20
    • 2014-03-18
    相关资源
    最近更新 更多