Create SSH Key or Bitbucket Token
This guide describes the process for setting up authentication on Bitbucket, including creating SSH keys for secure authentication or configuring the Git Credential Manager to save your authentication token.
Authentication on Bitbucket
There are two main ways to authenticate on Bitbucket: SSH keys and Git Credential Manager.
1. SSH Keys
SSH keys allow you to authenticate without needing to type your password every time.
1.1. Checking for Existing Keys
Check if you already have existing SSH keys:
ls -al ~/.ssh
If you see files like id_rsa and id_rsa.pub, you already have SSH keys. Otherwise, proceed to the next step.
1.2. Generating SSH Keys
Generate a new SSH key with the following command:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Replace your_email@example.com with your email address. Press Enter to accept the default location to save the key (usually ~/.ssh/id_rsa). Set a passphrase for your SSH key, or leave it blank to not use a passphrase.
1.3. Adding the Key to Bitbucket
-
Copy the Public Key:
- On Windows:
clip < ~/.ssh/id_rsa.pub - On macOS:
pbcopy < ~/.ssh/id_rsa.pub - On Linux:
cat ~/.ssh/id_rsa.puband copy it manually
- On Windows:
-
Add the Key to Bitbucket:
- Access Bitbucket and log in
- Click on your avatar in the top right corner
- Select "Settings"
- In the side menu, click "SSH keys"
- Click "Add key"
- Paste the public key into the "Key" field
- Give the key a descriptive name (e.g., "Work Laptop")
- Click "Add key"
1.4. Testing the SSH Connection
Test the SSH connection with Bitbucket:
ssh -T git@bitbucket.org
You should see a success message.
2. Git Credential Manager
The Git Credential Manager stores your authentication token so you don't have to type it repeatedly.
2.1. Windows
On Windows, the Git Credential Manager is installed automatically with Git for Windows. It stores your credentials securely.
2.2. macOS
brew install git-credential-manager-core
Then, configure Git to use the Credential Manager:
git config --global credential.credentialStore osxkeychain
2.3. Ubuntu/Linux
sudo apt-get update
sudo apt-get install git-credential-manager
Then, configure Git to use the Credential Manager:
git config --global credential.credentialStore secrets
3. Creating an App password (Alternative to SSH Keys)
If you prefer to use an app password instead of SSH keys:
- Access Bitbucket and log in
- Click on your avatar in the top right corner
- Select "Settings"
- In the side menu, click "App passwords"
- Click "Create app password"
- Give the password a name (e.g., "Local Development")
- Select the necessary permissions (usually "Repository read" and "Repository write")
- Click "Create"
- Copy the generated token (you will not be able to see it again)
When cloning a repository or pushing, use your username and the token as your password:
git clone https://your_username@bitbucket.org/team/repository.git
# When prompted, use the token as the password
Repository Setup
After setting up authentication, you can clone the project repository:
Using SSH
git clone git@bitbucket.org:team/repository.git
Using HTTPS with Token
git clone https://your_username@bitbucket.org/team/repository.git
# When prompted, use the token as the password
Next Steps
After setting up authentication on Bitbucket, you are ready to start working with the project repository. The next step is to install the development environment required for the bootcamp.