Skip to content

Instantly share code, notes, and snippets.

@dekadentno
Last active November 2, 2018 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dekadentno/016db404b8e648ac8cc05049e6148cce to your computer and use it in GitHub Desktop.
Save dekadentno/016db404b8e648ac8cc05049e6148cce to your computer and use it in GitHub Desktop.
Generate and import ssh keys for Gitlab and Bitbucket

How to generate and import ssh keys to git

Navigate to your .ssh folder and generate a ssh key. Put a name on it and a password.

ssh-keygen -t rsa

This command will generate 2 files (private and public keys):

key_name
key_name.pub

Navigate to Gitlab (or Bitbucket) settings and find the tab for importing your ssh key.

Important: when uploading/pasting your SSH key, you are importing just the public (.pub) key! Also, every project has to have the SSH url set in the git config file in order for this to work!

To test is the key is imported correctly, navigate in the terminal to your project and try to

git pull

After that, check in the Gitlab/Bitbucket SSH settings if the "last used" is changed to "1 minute ago" or so.

Important notice for Bitbucket: in order to make Bitbucket work, use the command to gather the public ssh key and link it with Bitbucket:

ssh-keyscan -t rsa bitbucket.org

IMPORTANT

Don't forget to change the path to the new ssh file in .ssh/config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment