关于git push heroku master 部署不到 heroku的解决方案

一般输入以下命令便可部署

git init
heroku git:remote -a 你的应用名称
git add .
git commit -am "init"
git push heroku master

这个过程出错,一般是报以下两个错误

1.fatal: unable to access 'https://git.heroku.com/myforums123.git/': error setting certificate verify locations:
  CAfile: D:/Git/mingw64/ssl/certs/ca-bundle.crt

  CApath: none

关于git push heroku master 部署不到 heroku的解决方案_第1张图片

2.Permission denied (publickey).

fatal: Could not read from remote repository.


解决方案:

步骤1.终端输入ssh-keygen,查看是否如下图所示,

关于git push heroku master 部署不到 heroku的解决方案_第2张图片

若显示ssh-keygen不是内部或外部命令,则自行配制环境变量,确保输入ssh-keygen如上图所示


步骤2.满足步骤1条件后,进入C:\User\.ssh (或者你直接在C盘 搜索.ssh文件)查看该文件下是否有以.pub为后缀的文件关于git push heroku master 部署不到 heroku的解决方案_第3张图片

此时有两种情况,

第一种就是你有这些文件说明你有公钥,需要将公钥上传到Heroku

第二种就是你没有这些文件,你需要添加一个公钥

第三种就是删除并添加heroku作为远程引用

查看现有的密钥的方法是:

heroku keys

清除现有的密钥的方法是:

heroku keys:clear

@第一种情况的解决方案

你需要把你的公钥上传到Heroku,进入

heroku keys:add ~/.ssh/id_rsa.pub (如果你已经进入.ssh目录就不需要写‘/.ssh’)


然后执行

git push heroku master

(不行的话使用

heroku keys:clear

 清除现有的密钥,使用第二种情况的解决方案


@第二种情况的解决方案

使用以下命令添加一个公钥

heroku keys:add

确保SSH检查正确目录中的密钥,执行以下操作:

ssh -vT [email protected]

其中将显示以下行:

OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Connecting to heroku.com [50.19.85.156] port 22.
debug1: Connection established.
debug1: identity file /c/Wrong/Directory/.ssh/identity type -1
debug1: identity file /c/Wrong/Directory/.ssh/id_rsa type -1
debug1: identity file /c/Wrong/Directory/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version Twisted
debug1: no match: Twisted
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Host 'heroku.com' is known and matches the RSA host key.
debug1: Found key in /c/Wrong/Directory/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /c/Wrong/Directory/.ssh/identity
debug1: Trying private key: /c/Wrong/Directory/.ssh/id_rsa
debug1: Trying private key: /c/Wrong/Directory/.ssh/id_dsa
debug1: No more authentication methods to try.

再次执行

git push heroku master

命令应该能正确部署

关于git push heroku master 部署不到 heroku的解决方案_第4张图片

@第三种情况解决方案:

1.先检查heroku

git remote -v

如果heroku存在,将其删除

git remote rm heroku

然后添加回来(注意下,下面这条命令的project,是你的heroku里面APP的名称)

git remote add heroku [email protected]:project.git

再次执行下面的命令应该可以成功

git push heroku master


<**********************************完毕*****************************************>

参考链接:

https://stackoverflow.com/questions/4269922/permission-denied-publickey-when-deploying-heroku-code-fatal-the-remote-end

https://stackoverflow.com/questions/28641851/cannot-push-to-heroku-fatal-unable-to-access-could-not-resolve-host-nil-n

https://stackoverflow.com/questions/17626944/heroku-permission-denied-publickey-fatal-could-not-read-from-remote-reposito

https://blog.csdn.net/R3lish/article/details/51972363

你可能感兴趣的:(关于git push heroku master 部署不到 heroku的解决方案)