1

In order to ensure security, I have added SSH public key to my Bitbucket account. This is working perfectly and no password is prompted since the private key is added to my machine using ssh-add command.

The problem I am facing now is it will not work after system restart. I have to use ssh-add command after every system restart. Can someone help me on this ?

I am using Ubuntu 18.04

kenlukas
  • 2,886
  • 2
  • 14
  • 25

1 Answers1

0

Did you follow the official documentation here: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html ??

Bitbucked instructions:

The steps for enabling ssh in bitbucket are the following:

In your workstation:

$ ssh-keygen

(you can omit the password here by pressing enter when asked if you wish to simply use the key-pair without entering a decryption password each time you login)

After this, verify the keys are generated:

$ ls -l ~/.ssh
id_rsa
id_rsa.pub

Now you need to add the keys to your bitbucket settings:

  • Go to the Account settings
  • Click ssh keys
  • Click Add key
  • Write a "Label" with a descriptive sentence ("User Tismon at Home Workstation", for ex.).
  • Copy the contents of ~/.ssh/id_rsa.pub into the "Key" field (use cat ~/.ssh/id_rsa.pub or open with a text editor, but make sure to copy everything from the file).
  • Click save
  • Verify everything is working as expected with ssh -T git@bitbucked.org

Encrypted ssh keys:

There is no need to do ssh-add unless you set up a password for the keys. If you did, you have to make sure the ssh-agent is running and make sure you add the private key:

$ eval `ssh-agent` 
$ ssh-add ~/.ssh/id_rsa

If you need an encrypted ssh-key, you have to ssh-add the key everytime you reboot, as ssh-add lasts as long as your session. If you don't want to enter the key or password everytime, the easiest way is not to encrypt it.

Leo
  • 1,833
  • 8
  • 17
  • Exact these steps are followed as advised from bitbucket documentation and it works. But dont know how it failed after every system restart. – Tismon Varghese Oct 29 '19 at 05:45
  • everytime whenever server restart either you have to load keys manually or add sometime to load automatically from rc.local or from profile to make it work after reboot. – asktyagi Oct 29 '19 at 06:26
  • 1
    @TismonVarghese Are you encrypting the key with a password? If you need an encrypted ssh-key, you have to ssh-add the key everytime you reboot, as ssh-add lasts as long as your session. If you don't want to enter the key or password everytime, the easiest way is not to encrypt it. – Leo Oct 30 '19 at 15:28