### Step 1: Check if SSH is Installed 1. Open a terminal. 2. Run: `ssh -v` - If it shows a version (e.g., OpenSSH), SSH is installed. If not, install it with: ```bash sudo apt update sudo apt install openssh-client ``` ### Step 2: Generate an SSH Key 1. In the terminal, generate a new SSH key: ```bash ssh-keygen -t ed25519 -C "your_email@example.com" ``` - Replace `"your_email@example.com"` with your email. - If your system doesn’t support `ed25519`, use: ```bash ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` 2. Press Enter to accept the default file location (`~/.ssh/id_ed25519` or `~/.ssh/id_rsa`). 3. Optionally, enter a passphrase for extra security (or leave blank). ### Step 3: Start the SSH Agent 1. Start the SSH agent: ```bash eval "$(ssh-agent -s)" ``` 2. Add your SSH private key to the agent: ```bash ssh-add ~/.ssh/id_ed25519 ``` - Use `~/.ssh/id_rsa` if you generated an RSA key instead. ### Step 4: Copy Your Public Key 1. Display your public key: ```bash cat ~/.ssh/id_ed25519.pub ``` - Or `cat ~/.ssh/id_rsa.pub` for RSA. 2. Copy the output (starts with `ssh-ed25519` or `ssh-rsa`). ### Step 5: Add the SSH Key to Bitbucket 1. Log in to your Bitbucket account. 2. Go to **Personal settings** > **SSH keys**. 3. Click **Add key**. 4. Paste your public key (from Step 4) and give it a label (e.g., "Ubuntu PC"). 5. Save it. ### Step 6: Test the Connection 1. In the terminal, test the connection to Bitbucket: ```bash ssh -T git@bitbucket.org ``` 2. If successful, you’ll see a message like: `"authenticated via ssh key ... You can use git to connect to Bitbucket..."` ### Step 7: Clone or Use a Repository 1. On Bitbucket, go to your repository and copy the SSH URL (e.g., `git@bitbucket.org:username/repo.git`). 2. In the terminal, clone it: ```bash git clone git@bitbucket.org:username/repo.git ``` - Replace the URL with your repository’s SSH URL. ### Troubleshooting - If you get a "Permission denied" error: - Ensure your public key is correctly added to Bitbucket. - Check file permissions: `chmod 600 ~/.ssh/id_ed25519` (or `id_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!