Skip to content

Instantly share code, notes, and snippets.

@jazio
Last active April 26, 2025 13:49
Show Gist options
  • Save jazio/04d39f4855c83eb507fa40cec23b494f to your computer and use it in GitHub Desktop.
Save jazio/04d39f4855c83eb507fa40cec23b494f to your computer and use it in GitHub Desktop.

Create the SSH Key.

ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/.ssh/gitlab25

Rename the result file from ~/.ssh/ to your own name: e.g. gitlab25

gitlab25 gitlab25.pub

ssh-add ~/.ssh/gitlab25

Rename it to

ssh-add -L
The agent has no identities.
eval "$(ssh-agent -s)"

To ensure the agent starts every time you open a terminal, add this to your shell configuration file (~/.bashrc, ~/.zshrc, or ~/.profile):

if [ -z "$SSH_AUTH_SOCK" ]; then
    eval "$(ssh-agent -s)"
fi

Once the agent is running, add your key:

ssh-add ~/.ssh/gitlab25

Store your SSH key passphrase (if needed)

Open or create your SSH config file:

vi ~/.ssh/config

Add the lines

Host gitlab.com
    IdentityFile ~/.ssh/gitlab25
    AddKeysToAgent yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment