Set up SSH on macOS for bitbucket
By the end of Feb 2022, bitbucket will require ssh to connect to the git repo and https connection will be disabled. Here are steps to change from https to ssh.
1. Set the repo origin url to use ssh, inside the project direction run the following, replace the url with yours.
git retmote set-url origin git@bitbucket.org:your_username/your_project_repo_name.git git remote -v
2. Go to the .ssh directory within your home directory, and generate a public/private rsa key pair. When prompted for filename, you can use the default or type in a name such as id_rsa_bitbucket. When prompted for passphrase, you can just press enter to skip it or enter a passphrase.
cd ~/.ssh ssh-keygen ls -l
3. Add the private key to ssh agent. Replace id_rsa_bitbucket with the file name you chose when creating the keys.
ssh-add -K ~/.ssh/id_rsa_bitbucket
4. Open or create the file config, and add the following to it. Replace id_rsa_bitbucket.pub with the file name you chose when creating the keys.
Host bitbucket.org AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_rsa_bitbucket.pub
5. Copy the content from id_rsa_bitbucket.pub. Replace id_rsa_bitbucket.pub with the file name you chose when creating the keys.
pbcopy < ~/.ssh/id_rsa_bitbucket.pub
6. Go to Bitbucket webpage, Personal Settings, SSH Keys, then click Add key. Enter a name, and then paste the content you copied from step 5, and save.
7. Go back to the terminal, and run the following to verify your configuration and username.
ssh -T git@bitbucket.org
8. If everything is set up correctly, it should show the following.
authenticated via ssh key. You can use git to connect to Bitbucket. Shell access is disabled
Search within Codexpedia
Search the entire web