Generate Ssh Key Ubuntu Bitbucket
Aug 10, 2019 Instructions how to install and run xplat-cli in Ubuntu 14.04 LTS with bash. Install and Configure the Azure Cross-Platform Command-Line Interface; Sources in GitHub. Generate ssh-keys: $ ssh-keygen -t rsa -b 4096-f /.ssh/foo -C 'me@example.com' Generating public/private rsa key pair. Enter passphrase.
- Apr 14, 2014 Hi Jared, try this command: ssh -T hg@bitbucket.orgIf you get a response like 'logged in as username. You can use git or hg to connect to Bitbucket. Shell access is disabled.' The ssh keys were configured correct and the problem may be something else, otherwise you may need to review your keys.
- My steps to generate and use the SSH key in Bitbucket: ssh-keygen -t rsa -C 'my email' cat /.ssh/idrsa.pub; copy my key ssh-rsa AAAAB3Nz. My email to clipboard; in bitbucket access my configuration SSH keys; add the key; in console of my ubuntu, I use the command: ssh -T git@bitbucket.org.
What does SSH Keys do in Github / Bitbucket?
Set up SSH to reduce the risk of exposing your username and password.Some reasons you might want to use SSH key base authentication:
- Is more effective if you push and pull from Bitbucket many times a day.
- Removes the need to enter a password each time you connect.
Url formats of the repository differs from HTTPS
to SSH
:
Environment
- Operating System : Ubuntu 16.04 LTS (64-bit)
Add SSH Keys in Ubuntu 16.04
The following steps showed the step by step installation guideline.
Set up your default identity
From the terminal, enter ssh-keygen
at the command line.The command prompts you for a file to save the key in:
It will create two files; one public key file and one private key file.Both file will have your given name.
Add Key files in local machine
Keep both of the files in ~/.ssh
location.
Add the public key to your bitbucket settings
- In Bitbucket go to
Bitbucket settings>Account settings>SSH keys>Add key
- Copy the contents of your public key file using the following command:
N.B.: id_rsa
is the name I have given when generating the key files. It might be something else for your case.3. Copy and paste the public key in the key
field in Bitbucket and include proper label. Click Save
.
Ensure Bitbucket SSH connects successfully
Return to the terminal window and write:
For github
Give your passphrase which you have given when generating the key files.If your connection is successful then you will get output like following: Windows upgrade anytime key generator.
For Github:
References
- Set up an SSH key: Bitbucket documentation
- Change existing folder remote url: Github documentation
June, 2017 update: Setup SSH key for local dev box and use agent forwarding for servers
Create/setup the key on your server:
- Login to server using SSH/terminal.
- Depending on your setup, you may need to
$ su -
and enter the root user’s password (depending on the steps you take below, this will create files in that user’s home directory with root permissions). - List the contents of
.ssh
directory:$ ls -a ~/.ssh
and check for an existingid_rsa.pub
; use that default identity in BitBucket (skip to next heading) or … - At the command prompt, type:
$ ssh-keygen
. - Follow the on-screen instructions (on a production machine, a password should be entered for security purposes).
- For comparison’s sake, list the contents of
.ssh
directory:$ ls -a ~/.ssh
. - Check to see if
ssh-agent
is running:$ ps -e grep [s]sh-agent
. - If not (above command returns nothing) then run:
ssh-agent /bin/bash
. - Add newly-created key to the
ssh-agent
:$ ssh-add ~/.ssh/id_rsa
. - View list of keys the
ssh-agent
is managing:$ ssh-add -l
. - Run
$ cat ~/.ssh/id_rsa.pub
and copy the output to your clipboard.
Reversing the above process is easy:

Add key to BitBucket
- On BitBucket, choose
avatar
>Manage Account
. - Switch to the account you want to manage and click
SSH keys
; add a new key which should be named to match the server name (e.g.,dev.foodomain.com
). - Paste the key into the
Key
field and clickAdd key
.
Clone BitBucket repo
- Go to your repo in BitBucket and copy the
SSH
URI (e.g.,git@bitbucket.org:user-name/repo-name.git
). - SSH to your server and navigate to the location you want to clone the repo to.
- From the command line, run:
$ git clone git@bitbucket.org:user-name/repo-name.git
. Note: If you want to specify the folder name that the repo clones into, add that to the end of the command (e.g.,git clone git@bitbucket.org:user-name/repo-name.git target-folder-name
).
Bitbucket Generate Ssh Key Ubuntu
Done!
Pulling updates
- SSH to your server.
- Navigate to your repo:
$ cd target-folder-name/
. - Run
$ git remote update && git status
$ git fetch
. - If there are changes to pull, then run
$ git pull
. - Optionally re-run
$ git remote update && git status
$ git fetch && git pull
to see if everything is clean.