SSH Keys
Guide for generating and managing SSH keys for access to GitLab and company servers.
Generating a Key
bash
ssh-keygen -t ed25519 -C "yourname@etnetera.cz"When prompted for a path, press Enter (default ~/.ssh/id_ed25519). Set a strong passphrase.
TIP
We recommend the ed25519 type — it is more secure and shorter than RSA. If a server requires RSA: ssh-keygen -t rsa -b 4096 -C "yourname@etnetera.cz"
Adding the Key to ssh-agent
macOS
bash
eval "$(ssh-agent -s)"
ssh-add --apple-use-keychain ~/.ssh/id_ed25519Add to ~/.ssh/config:
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519Linux
bash
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Adding the Key to GitLab
- Copy the public key:
bash
cat ~/.ssh/id_ed25519.pub | pbcopy # macOS
cat ~/.ssh/id_ed25519.pub | xclip # Linux- Go to
gitlab.etnetera.cz→ User Settings → SSH Keys - Paste the key, give it a name (e.g.
MacBook-2024) and save
Verification
bash
ssh -T git@gitlab.etnetera.czMultiple Keys (optional)
If you use multiple accounts or keys, configure ~/.ssh/config:
# Company GitLab
Host gitlab.etnetera.cz
HostName gitlab.etnetera.cz
User git
IdentityFile ~/.ssh/id_ed25519_etnetera
# Personal GitHub
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personalSecurity
- Never share your private key (
id_ed25519without.pub) - Always use a passphrase
- If a device is lost or compromised, immediately remove the key from GitLab and notify the IT team