I have a private repo that I'm trying to access when deploying to Heroku. However, Heroku doesn't let me clone the private repo, and gives me the following error (as i would expect):
Host key verification failed.
fatal: The remote end hung up unexpectedly
Git error: command `git clone
'[email protected]:pr/lm-models.git'
"/tmp/build_3r0z0znww0zda/vendor/bundle/ruby/1.9.1/cache/bundler/git/lm-models-aab025aaadbe07202b16e1db7505ae1726f8723a"
--bare --no-hardlinks` in directory /tmp/build_3r0z0znww0zda has failed.
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
I have found this, but do not want to display my username/password in clear text:
Linking heroku app to a private(organization) github repo
Heroku does not have the private keys necessary to access your private Github repositories, and as such, attempts to access those private repos will fail. Rather than providing Heroku with the private keys necessary to access your Github repo, its much better to use OAuth tokens.
Public repositories are accessible to everyone on the internet. Private repositories are only accessible to you, people you explicitly share access with, and, for organization repositories, certain organization members.
No, the code is not public. Do not confuse GIT with GITHUB. When you deploy to heroku the repository is private to the owner and the added collaborators.
This worked for me:
In requirements.txt list private module as follows:
git+https://your_user_name:[email protected]/your_company/your_module.git
Heroku only supports HTTP(S) Basic authentication with Git out of the box. That's unfortunate as it means you'd need to add your credentials as part of the installation URL and commit that as plain text in your list of dependencies. For your app to support SSH keys instead, do the following:
id_rsa_heroku
.heroku buildpacks:add https://github.com/heroku/heroku-buildpack-ssh-key.git -i 1
heroku config:set BUILDPACK_SSH_KEY=$(cat ~/.ssh/id_rsa_heroku)
From this moment, Heroku should be able to access and download code from any private repositories you have access to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With