My steps to generate and use the SSH key in Bitbucket:

  1. ssh-keygen -t rsa -C "my email"
  2. cat ~/.ssh/id_rsa.pub
  3. copy my key ssh-rsa AAAAB3Nz... my email to clipboard
  4. in bitbucket access my configuration > SSH keys
  5. add the key
  6. in console of my ubuntu, I use the command: ssh -T [email protected]

After using the command from step 6, the following message appears:

$ ssh -T [email protected]logged in as ricardoramos.You can use git or hg to connect to Bitbucket. Shell access is disabled.

When I make a push to my repository, still continues requiring my password.

It is very annoying to have to keep typing the password for every push.

Where am I wrong?

3

Best Answer


You can't login to bitbucket's shell using SSH, but you did set up your key correctly, otherwise you wouldn't have gotten the "Shell access is disabled" message.

What you have to do is change the URL of your repo. Right now you have a HTTPS URL set, which requires a password. You can switch to an SSH URL like this:

git remote set-url origin [ssh url of your git repo]

You need to use an ssh agent. try

$ ssh-add

before pushing. Supply your passphrase when asked.

If you aren't already running an ssh agent you will get the following message:

Could not open a connection to your authentication agent.In that situation, you can start one and set your environment up thusly

eval $(ssh-agent)

Then repeat the ssh-add command.

It's worth taking a look at the ssh agent manpage.

Go through this page you would get an better idea http://jonathannicol.com/blog/2013/11/19/automated-git-deployments-from-bitbucket/

Environment Ubuntu 20.04 and 22.04

$ mkdir .ssh$ cd .ssh/$ ssh-keygen -t ed25519 -b 4096 -C "[email protected]" -f bitbucket-ssh (file name to store private/public key)# when asked for passphrase - add passphrases if you want - if passphrase provided then it will ask git command will be fired.$ ls -l$ ssh-add ~/.ssh/bitbucket-ssh$ nano config# add this file to ensure the correct identity token is used the content of this file looks like - Host bitbucket.orgAddKeysToAgent yesIdentityFile ~/.ssh/bibucket-ssh$ cat bitbucket-ssh.pub $ ssh -T [email protected]

To test bitbucket cloud host the output of this command something like (on successful connection establishment) -
RSA key fingerprint is SHA256:xxxxxxxxxxxxxxE8AikJYKwbHaxvSc0ojez9YXaGp1A.This key is not known by any other namesAre you sure you want to continue connecting (yes/no/[fingerprint])? yes - (when prompt type yes and press enter)Warning: Permanently added 'bitbucket.org' (RSA) to the list of known hosts.authenticated via ssh key.You can use git to connect to Bitbucket. Shell access is disabled.

bitbucket-ssh.pub file content must be added to bitbucket under SSH key section.for details - https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-linux/