3

I want to deploy rails app without using Heroku ToolBelt. Is it possible? If so, how? I'm only allowed to use Heroku dashboard; I'm not allowed to use any other cloud service :(

I have to run PostgreSQL commands, adding add-ons and setting configuration variables and possibly other tasks for which we have Heroku Toolbelt to deploy a application in production environment.

Error:

user@xx ~/Desktop/github/blog (master)
$ git push git@heroku.com:herokugui.git master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I don't want to use Heroku Toolbelt. That's why I am using Git commands to deploy code on Heroku. I am not able to push code to Heroku using Git commands. Is it possible to do this task without the toolbelt?

Another question I have is: is there any way to run PostgreSQL commands on Heroku GUI? If so, how?

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Ajay Gupta
  • 192
  • 1
  • 12

1 Answers1

8

It's not easy (as with Heroku toolbelt), but it's possible. It involves hanging around your Heroku dashboard at least, so make sure you can access it.

First off, you need a key. If you're on a Linux machine (as me), then in your home directory you should have a folder named .ssh (it may be hidden, hit Ctrl+H to reveal, again, if Linux) and a file id_rsa.pub in there. If not, you need to generate your SSH key first.

ssh-keygen -t rsa

That will prompt you for a folder, default is fine, just hit Enter, then enter the passphrase (twice) to protect your key from being accessed by anyone else on your computer: without a passphrase it's unencrypted and free for anyone to take and use from that machine.

Once that is done, locate your public key file: id_rsa.pub. Note: not id_rsa, it's a private key, you may not want to give it to anyone, it's much like your future Heroku password, except for it's insanely large for a password. Open id_rsa.pub, you should see stuff like:

ssh-rsa aWhOLELotofUnreadABLEGibbERishWHiCHiSactUALLyYourPubLIcKeY...

You need to enter that line into your account settings in Heroku dashboard, under SSH Keys. You can find more info on keys here, in Heroku docs. Make sure Heroku actually recognizes you by issuing this:

ssh -v git@heroku.com

It should state you're authenticated.

Now for the git address. I assume you know your way around git, so I'll keep it short: you'll need to derive your repository address from your app name. Heroku usually generates weird (yet somewhat poetic) names like falling-wind-1624 or shielded-fjord-1858. I'll take the first one as an example, this is how you add its address as a git remote:

git remote add heroku git@heroku.com:falling-wind-1624.git

I'll explain a bit of it below. So what the toolbelt does here, is to use your app name only, it just builds the URL the same way by adding a path to Heroku server. Once that's done, you should be able to push your code:

git push heroku master

I've named a Heroku remote heroku, above, that's why I'm using heroku name here, you can name it whatever you want and use this afterwards. Once you've pushed the code, the rest is up to you.

D-side
  • 9,150
  • 3
  • 28
  • 44
  • 1
    Great little guide, thanks. Minor difference I encountered were that I had to do `git push heroku master` for the last step, and I looked up the remote address from the Settings tab in the interface. – Asfand Qazi Jun 21 '15 at 08:54
  • @AsfandYarQazi actually, yes, they've added it to the dashboard quite a while ago. And I edited the last command to include the branch name, since letting `git` guess the remote branch requies some insight into `git`. – D-side Jun 21 '15 at 08:59