You have to upload your public key to Heroku:
heroku keys:add ~/.ssh/id_rsa.pub
If you don't have a public key, Heroku will prompt you to add one automatically which works seamlessly. Just use:
heroku keys:add
To clear all your previous keys do :
heroku keys:clear
To display all your existing keys do :
heroku keys
EDIT:
The above did not seem to work for me. I had messed around with the HOME
environment variable and so SSH was searching for keys in the wrong directory.
To ensure that SSH checks for the key in the correct directory do :
ssh -vT git@heroku.com
Which will display the following ( Sample ) lines
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.
Permission denied (publickey).
From the above you could observe that ssh looks for the keys in the /c/Wrong/Directory/.ssh
directory which is not where we have the public keys that we just added to heroku ( using heroku keys:add ~/.ssh/id_rsa.pub
) ( Please note that in windows OS ~
refers to the HOME
path which in win 7 / 8 is C:\Users\UserName
)
To view your current home directory do : echo $HOME
or echo %HOME%
( Windows )
To set your HOME
directory correctly ( by correctly I mean the parent directory of .ssh
directory, so that ssh could look for keys in the correct directory ) refer these links :
SO Answer on how to set Unix environment variable permanently
SO Question regarding ssh looking for keys in the wrong directory and a solution for the same.
Heroku links your projects based on the heroku
git remote (and a few other options, see the update below). To add your Heroku remote as a remote in your current repository, use the following command:
git remote add heroku git@heroku.com:project.git
where project
is the name of your Heroku project (the same as the project.heroku.com
subdomain). Once you've done so, you can use the heroku xxxx
commands (assuming you have the Heroku Toolbelt installed), and can push to Heroku as usual via git push heroku master
. As a shortcut, if you're using the command line tool, you can type:
heroku git:remote -a project
where, again, project
is the name of your Heroku project (thanks, Colonel Panic). You can name the Git remote anything you want by passing -r remote_name
.
[Update]
As mentioned by Ben in the comments, the remote doesn't need to be named heroku
for the gem commands to work. I checked the source, and it appears it works like this:
- If you specify an app name via the
--app
option (e.g. heroku info --app myapp
), it will use that app.
- If you specify a Git remote name via the
--remote
option (e.g. heroku info --remote production
), it will use the app associated with that Git remote.
- If you specify no option and you have
heroku.remote
set in your Git config file, it will use the app associated with that remote (for example, to set the default remote to "production" use git config heroku.remote production
in your repository, and Heroku will run git config heroku.remote
to read the value of this setting)
- If you specify no option, the gem finds no configuration in your
.git/config
file, and the gem only finds one remote in your Git remotes that has "heroku.com" in the URL, it will use that remote.
- If none of these work, it raises an error instructing you to pass
--app
to your command.
Best Answer
You can install the free New Relic add-on. It has an availability monitor feature that will ping your site twice per minute, thus preventing the dyno from idling.
More or less the same solution as Jesse but maybe more integrated to Heroku... And with a few perks (performance monitoring is just great).