Check that you do not already have a key
use sudo su to enter root
cd ~/.ssh
if it says bash: cd: /root/.ssh: No such file or directory, then you do not have a key
next, generate a key via ssh-keygen -t rsa
press enter at Enter file in which to save the key and Enter passphrase, just use default
your key will be saved in .ssh/id_rsa.pub
copy the content in .ssh/id_rsa.pub, gedit id_rsa.pub
to the manage account -> SSH keys in bitbucket
to test that you have valid connection, use ssh -T git@bitbucket.org, and enter yes
then you will see You can use git or hg to connect to Bitbucket. Shell access is disabled.
To use the key, you have to change the HTTP to SSH
use cat .git/config, you will see the url
edit the config file, accordingly
SSH URL format
|
HTTPS URL format
| |
---|---|---|
Mercurial | ssh://hg@bitbucket.org/ | https://accountname@bitbucket.org/accountname/reponame |
Git | git@bitbucket.org:accountname/reponame.git
or
ssh://git@bitbucket.org/accountname/reponame.git | https://accountname@bitbucket.org/accountname/reponame.git |
now you have to set chmod 400 ~/.ssh/id_rsa
then ssh-add ~/.ssh/id_rsa
Unfortunately, after all these hard work, my bitbucket still asks me for password. I use SmartGit instead, which is a GUI like sourceTree. Note that OpenJDK has to be installed beforehand in synaptic.
After all these mass, if you want to switch back to http, just delete the SSH stored in the bitbucket account.
No comments:
Post a Comment