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
'git#github.com: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
This worked for me:
Generate a Github Access Token
In requirements.txt list private module as follows:
git+https://your_user_name:your_git_token#github.com/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:
Create a new SSH key which will be used by Heroku to access the GitHub repository. Choose a distinct name, e.g. id_rsa_heroku.
Add the public part of the key to your GitHub account (link to settings).
Use the heroku-buildpack-ssh-key: heroku buildpacks:add https://github.com/heroku/heroku-buildpack-ssh-key.git -i 1
Set the private part of the key as an environment variable for your Heroku app: 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.
You need to use username/password in the Gemfile, or vendor the dependency. You can also use Gemfury (assuming it's a gem):
https://devcenter.heroku.com/articles/git-submodules#vendoring
http://gembundler.com/v1.3/bundle_package.html
https://devcenter.heroku.com/articles/gemfury
Related
I'm working on deploying a Phoenix app to Heroku, but several of the dependencies are in private Gitlab repos, and I am having trouble gaining access to them via SSH. When I try to push my app up, I hit the following error related to one of the dependencies (to which I normally have SSH access on my local machine):
remote: -----> Fetching app dependencies with mix
remote: * Getting cool_dep (git#gitlab.com:group/cool_dep.git)
remote: Host key verification failed.
remote: fatal: Could not read from remote repository.
remote:
remote: Please make sure you have the correct access rights
remote: and the repository exists.
So here's what I've done so far - if anyone can tell me what I'm missing or have done wrong, it would be much appreciated...
Generated a new public/private key pair for this Heroku deployment. I put the public key into the SSH keys in my Gitlab settings. (the keys do not have a secret passphrase)
Added the debitoor/ssh-private-key buildpack to my buildpacks so that they read like so:
https://github.com/debitoor/ssh-private-key-buildpack.git
https://github.com/HashNuke/heroku-buildpack-elixir.git
https://github.com/gjaldon/heroku-buildpack-phoenix-static.git
Added the private key counterpart of the public key to the app's config:
$ heroku config:set SSH_KEY=$(cat /Users/username/.ssh/heroku_id_rsa | base64) --app cool-app-12345
Set the SSH hosts in the app's config:
$ heroku config:set SSH_HOSTS="git#gitlab.com" --app cool-app-12345
And finally, when I run git subtree push --prefix local_app cool-app-12345 master, it starts to load up but then flops when it hits the first private dependency.
Can anyone clarify what I am missing here? Why is that host key verification failing?
also worth noting - I tested the public/private key pair by doing a basic $ git clone ... and that worked just fine, so the key relationship is valid... just seems to be a problem when Heroku gets in the mix.
I pulled the source code for the buildpack and started poking around - I found that the SSH_HOST config variable that I was setting - git#gitlab.com - was not being found, and it was just defaulting to the single git#github.com host that's hard-coded in... the docs say that you can add additional hosts, but it didn't seem to be working for me.
I was able to resolve this issue by cloning the buildpack and replacing line 13 in bin/compile with
ssh_hosts=${SSH_HOSTS:-"git#gitlab.com"}
So if your private repos are in Github, you're probably fine... but if they're on a different host, you may need to grab the buildpack code and host it on your own repo with custom hosts.
I've created a Team in Heroku and now I'd like to create an app inside that team from the cli, but there seem to be no team related cli flags.
I'm basically hoping for something like:
heroku create myteamapp --org myteam
I could also create the app in the online dashboard, but when I do that and I clone the app I can't push for some reason. What I did (I suplemented names for fake names):
$ git:clone -a myteamapp
Cloning into 'myteamapp'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
$ git remote -v
heroku https://git.heroku.com/myteamapp.git (fetch)
heroku https://git.heroku.com/myteamapp.git (push)
$ git push heroku master
error: src refspec master does not match any.
error: failed to push some refs to 'https://git.heroku.com/myteamapp.git'
The app is listed when I run heroku apps --org myteam.
The info that heroku info returns seems valid, the Git URL matches the remote url, the region is eu, which I configures in the online dashboard.
My user is listed as admin in the access section of the online dashboard for that app.
There was no team relevant docs in:
devcenter.heroku.com/articles/creating-apps
devcenter.heroku.com/articles/git-clone-heroku-app
There was no cli relevant docs in:
devcenter.heroku.com/articles/heroku-teams
I should have checked heroku help create. This lists -o or --org as flags to specify the organization.
The errors I got after trying that,that confused me where related to git; I didn't have any commits yet.
I am starting out with heroku and am following the getting to start with heroku tutorial. I am on windows 7 and am using Windows powershell as the command line.
The commands that I am using are
git clone git://github.com/heroku/ruby-sample.git
cd ruby-sample
heroku login
heroku create
git push heroku master
heroku open
The directory was cloned and after heroku login I got Authentication successful. in the command line. After heroku create I got
Creating immense-lowlands-8694... done, stack is cedar
http://immense-lowlands-8694.herokuapp.com/ | git#heroku.com:immense-lowlands-8694.git
Git remote heroku added
so the app was added to my heroku account. But there was problem with git push heroku master. I got
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What I have tried so far
This question said about adding keys but it is for Linux and didn't work for Windows 7.
I used heroku keys and it says that there is a key present for my e-mail ID.
As this answer says I tried heroku keys:add and got
this
Found existing public key: C:/Users/Aseem/.ssh/github_rsa.pub
Uploading SSH public key C:/Users/Aseem/.ssh/github_rsa.pub... done
but after that the error didn't end.
I tried what this answer says but ssh-keygen wasn't recognized so I guess it's for linux.
I tried removing using heroku keys:remove KEY_NAME and then heroku login to login again but that didn't take care of the error either.
What can I do to solve the problem?
Installed MSysGit instead of git. Added the C:\Program Files(x86)\Git\bin directory to the PATH variable and then doing what this answer says solved the problem.
Environment: Windows 7
I go to Start | Run and type cmd.
I changed to my directory on my local hard drive and I was able to successfully clone the Github project:
git clone git://github.com/heroku/ruby-sample.git
I then change to the directory:
cd ruby-sample
I'm able to run the Heroku create:
heroku create
I log into Heroku via Firefox and I can see my App directory on Heroku. So far, so good. Then I try and push:
git push heroku master
and every time I get the same error:
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I've Googgled and looked at a number of similar questions; but unfortunately, I'll be the first to admin that Linux is a very weak area for me. I haven't found an answer that is specific to this setup on a Windows 7 environment. I do have the Heroku Toolbelt installed.
Thank you!
V
(I realized I assumed Rails here and you did not specify that. If you aren't using Rails, ignore the comment about RailsInstaller and RailsBridge.)
You may need to add your ssh key to your heroku setup with:
heroku keys:add
If you used RailsInstaller, that should just work. If not, and you don't have an ssh key pair, you'll need to look up how to do that first. You can use PuTTY to do that: http://kb.site5.com/shell-access-ssh/how-to-generate-ssh-keys-and-connect-to-your-account-with-putty/
For a full procedure that will get an app bootstrapped onto Heroku with a Rails app, see: http://installfest.railsbridge.org/installfest/installfest
I create a heroku app and then my machine crashed. I have a new machine. How do I attach my existing app to heroku app. When I visit heroku page the url for my app is like this
git#heroku.com:myapp.git
I can't do clone this app because I already have myapp from github. So I need to add heroku as remote to my existing github app. Anyone knows the syntax.
If you've heroku toolbelt:
If you're using the Heroku Toolbelt, the newer syntax is
heroku git:remote -a project
See this for more.
Credits: user101289's solution
Else if you don't have heroku toolbelt:
First do this:
git remote add heroku git#heroku.com:{heroku-app-name}.git
Then do this:
git push heroku master
heroku open
If you're using the Heroku Toolbelt, the newer syntax is
heroku git:remote -a project
See this for more.
If you're using just Git without installing the Heroku Toolbelt, you can also create a new application.
Login to your account and go to this link
https://dashboard.heroku.com/apps
Look at the plus sign on the top right corner then select
Create new app
Leave the application name blank to let heroku choose one for you.
Let say your heroku app name is new-app-xxxxx, so to test on adding a file in to it you may try the following command:
git clone https://git.heroku.com/<new-app-xxxxx>.git
cd <new-app-xxxxx>
echo "my test file" > test.txt
git add .
git commit . -m "my test on commit"
git push
Put empty (blank) when the Git prompt for username, and your API Key for the password. You can get your API Key by showing it from the link below.
https://dashboard.heroku.com/account
Note: You cannot authenticate with the Heroku HTTP Git endpoint using your Heroku username (email) and password. Use an API key as described here.