Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#Up to date doc can be found on https://gitlab.com/help/ssh/README#generating-a-new-ssh-key-pair
#First configure your local git configuration so it can communicate with your gitlab server :
# If you're on windows install git bash for windows if not install git
# This time i'm on windows so :
#Open a git bash command terminal (right click into any folder + git bash here)
#Generate a new ED25519 SSH key pair
#(as a best practice we should always prefer ED25519 to old rsa format)
#(as a best practice dont forget to add a strong passkey and save it in your keypass)
ssh-keygen -t ed25519 -C "YourEmail@YOUR_COMPANY.com"
#Clip the generated public key to copy it into your gitlab console
cat ~/.ssh/id_ed25519.pub | clip
#Open the gitlab console and Paste the clipped public key into your (Profile Menu > Settings > SSH Key > Key) + Add it
#in your git bash console run :
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_ed25519
#specify which ssh key to use for your gitlab
vi ~/.ssh/config
# Company GitLab instance (ensure gitlab.YOUR_COMPANY.com is your gitlab url)
Host gitlab.YOUR_COMPANY.com
Preferredauthentications publickey
IdentityFile ~/.ssh/id_ed25519
#:wq(to save and quit vi)
#To verify that your local git can communicate with the gitlab server in ssh run :
#(ensure your gitlab url is gitlab.YOUR_COMPANY.com)
ssh -T git@gitlab.YOUR_COMPANY.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.