Think of SSH keys as your gatekeeper to GitLab minus the small talk and awkward passwords. This short guide walks you through generating a modern key pair registering the public key with GitLab and using ssh agent tricks to avoid typing your way into madness. It is a practical DevOps tutorial for people who care about security but also have deadlines.
Use a modern key type for better security and less drama. Ed25519 is a good default because it is secure and tiny. If you prefer RSA for compatibility that works too but pick at least 3072 bits.
ssh-keygen -t ed25519 -C "your_email@example.com"
Press Enter to accept the default path unless you want a custom file name. Add a passphrase if you want an extra lock on the private key. Leave it blank when you need unattended automation for pipelines.
Copy the public key and paste it into the GitLab web console under Profile Settings then SSH Keys. On Unix like systems do this to view the key.
cat ~/.ssh/id_ed25519.pub
Give the key a clear title that future you can scan without a panic attack. Include host or purpose like work laptop or ci runner.
Let the agent hold your private key so you are not typing your passphrase a dozen times. On a Unix like shell run these commands.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
On Windows use the OpenSSH agent service or a GUI key manager such as the one bundled with Git for Windows. The goal is the same. Make the agent cache the key so git push and git pull stop sounding like a broken elevator.
If you have personal and work accounts or multiple GitLab instances a simple SSH config picks the right key per host. Create or edit the file at ~/.ssh/config and set permissions to user only.
Host gitlab.com
User git
IdentityFile ~/.ssh/id_ed25519
Host gitlab-work
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_ed25519_work
Then use git remote set-url or add a remote that points to the correct Host entry. This prevents accidental pushes from the wrong account when you are juggling identities like a tired circus performer.
Verify GitLab recognizes your key with a test authentication. You will get a friendly or at least informative message if things work.
ssh -T git@gitlab.com
A successful auth will show a welcome message. After that add SSH remotes or update existing ones and push or pull as usual. Example remote form is git@gitlab.com:username/repo.git but the ssh test uses the git at host syntax.
There you go. Secure GitLab SSH access without the drama and with enough sarcasm to keep you awake while you finish the merge request.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.