3

I created a public key for ssh and registered that key with BitBucket. I then attempted to push:

$ hg push ssh://[email protected]/johncharrell/[project name]
pushing to ssh://[email protected]/johncharrell/[project name
running ssh [email protected] "hg -R johncharrell/[project name serve --stdio"
remote: Warning: Permanently added the RSA host key for IP address '[server IP]' to the list of known hosts.
remote: Permission denied (publickey).
abort: no suitable response from remote hg!

What do I need to do so that my public key (or some other created for the purpose) will let me do an hg push from the shell or crontab? In BitBucket, I have read and write permissions to the project, but not to my knowledge anything administrative.

Anthon
  • 78,313
  • 42
  • 165
  • 222
Christos Hayward
  • 529
  • 1
  • 6
  • 17
  • 1
    The error `Permission denied (publickey)` basically means your public key is either missing from bitbucket or its somehow invalid. Try making a new `.pub` key with `ssh-keygen` and delete the old one referring to your host machine and register it. –  Sep 14 '12 at 19:15
  • 4
    Are you sure you are using the [correct URL format](https://confluence.atlassian.com/display/BITBUCKET/Using+the+SSH+protocol+with+bitbucket)? Normally, it would be: `ssh://[email protected]/accountname/reponame/` – jasonwryan Sep 14 '12 at 19:42

1 Answers1

0

To allow pushing, you should upload your public key to bitbucket you can do so with:

  • clicking your login icon at the top-right and selecting bitbucket settings
  • on the left in the section "SECURITY" select "SSH keys"
  • select "Add key" and upload your public key

After that you should be able to upload with any account that has the matching private key installed, even from a cron job.

I also recommend you create your repository first on bitbucket first then use the ssh parameter for hg provided by BitBucket to pull with mercurial. After that you can just do hg push without any parameters.

If you already have a repository, you have to do this in a new directory and copy your initial changes over the repository freshly checked out from BitBucket.

Anthon
  • 78,313
  • 42
  • 165
  • 222
  • You can also fix the repository url in local copy's `.hg/hgrc` (section `[paths]`, key `default`). – peterph May 09 '13 at 09:59