-
Open a terminal.
-
Run:
ssh -v
- If it shows a version (e.g., OpenSSH), SSH is installed. If not, install it with:
sudo apt update sudo apt install openssh-client
- If it shows a version (e.g., OpenSSH), SSH is installed. If not, install it with:
- In the terminal, generate a new SSH key:
ssh-keygen -t ed25519 -C "[email protected]"
- Replace
"[email protected]"
with your email. - If your system doesn’t support
ed25519
, use:ssh-keygen -t rsa -b 4096 -C "[email protected]"
- Replace
- Press Enter to accept the default file location (
~/.ssh/id_ed25519
or~/.ssh/id_rsa
). - Optionally, enter a passphrase for extra security (or leave blank).
- Start the SSH agent:
eval "$(ssh-agent -s)"
- Add your SSH private key to the agent:
ssh-add ~/.ssh/id_ed25519
- Use
~/.ssh/id_rsa
if you generated an RSA key instead.
- Use
- Display your public key:
cat ~/.ssh/id_ed25519.pub
- Or
cat ~/.ssh/id_rsa.pub
for RSA.
- Or
- Copy the output (starts with
ssh-ed25519
orssh-rsa
).
- Log in to your Bitbucket account.
- Go to Personal settings > SSH keys.
- Click Add key.
- Paste your public key (from Step 4) and give it a label (e.g., "Ubuntu PC").
- Save it.
- In the terminal, test the connection to Bitbucket:
ssh -T [email protected]
- If successful, you’ll see a message like:
"authenticated via ssh key ... You can use git to connect to Bitbucket..."
- On Bitbucket, go to your repository and copy the SSH URL (e.g.,
[email protected]:username/repo.git
). - In the terminal, clone it:
git clone [email protected]:username/repo.git
- Replace the URL with your repository’s SSH URL.
- If you get a "Permission denied" error:
- Ensure your public key is correctly added to Bitbucket.
- Check file permissions:
chmod 600 ~/.ssh/id_ed25519
(orid_rsa
).
- If asked about the host key, type
yes
to accept it.
That’s it! You should now be connected to Bitbucket via SSH on Ubuntu. Let me know if you run into any issues!