SSH into your server
Run
ssh-keygen -t rsato generate a public and private key pairIt will ask you where you to save the files. I recommend
/root/.ssh/bitbucketIt will ask you to choose a passphrase. Since we're just using this for deployments, you can leave the passphrase blank. If a hacker manages to steal these files, they probably have access to the code on your server anyway (which is all that this key will give them access to).
Run
cat /root/.ssh/bitbucket.pub. It will spit out your newly generated public key. Copy it to your clipboard.On bitbucket.org, go into your repo settings, click Deployment keys on the left and paste in your new key
Run
nano /root/.hgrcAdd this to the file:
[ui] ssh = ssh -i /root/.ssh/bitbucket [trusted] users = www-datacdinto your project directoryhg clone ssh://hg@bitbucket.org/NAME/PROJECT .(The trailing dot clones into the current directory if you've already created it -- make sure it's empty or this won't work)It should clone succesfully now. You can
hg pull && hg up --cleanwhenever you like without any passwords. This might not be the most robust way to deploy, but it's quick and easy.
Substitute root for your username if you SSH in as someone else.