Create Key (no passphrase and name mirror the key)
ssh-keygen -t rsa -N "" -f ~/.ssh/mirror
Create a file in ~/.ssh/config
(or edit) with this data (for github/bitbucket)
host github
hostname github.com
user git
identityfile ~/.ssh/mirror
host bitbucket
hostname bitbucket.org
user git
identityfile ~/.ssh/mirror
ssh github
ssh bitbucket
Create the hook(post-receive) in the repo (for example mirror-test.git bare repo)
cd /home/git/repositories
mv ./mirror-test.git/hooks/post-receive.sample ./mirror-test.git/hooks/post-receive
Edit this recent created hook (we are going to use github and bitbucket with the ssh key and config created previously)
git push --mirror github:slok/$GL_REPO.git
git push --mirror bitbucket:slok/$GL_REPO.git
We are using gitolite $GL_REPO variable
Dont forget to add the mirror.pub key to github/bitbucket! and create the repository