Skip to content

Instantly share code, notes, and snippets.

@ArthurDelannoyazerty
Created June 27, 2025 13:18
Show Gist options
  • Save ArthurDelannoyazerty/bf73d6c2534cd31e82a23675b05b35bc to your computer and use it in GitHub Desktop.
Save ArthurDelannoyazerty/bf73d6c2534cd31e82a23675b05b35bc to your computer and use it in GitHub Desktop.

SSH

Create ssh public & private key (Linux & Windows)

ssh-keygen
  1. You will be asked the location to store the ssh keys (default : ~/.ssh/id_rsa)
  2. You will be asked the ssh passphrase 2 times
  3. Then the keys will be generated (public: id_rsa.pub | private: id_rsa)
  4. You can now copy your public key and send it to some services while keeping the private key a secret on your machine

NOTE : If you set a non empty passphrase, every time you want to use the ssh key the passphrase will be asked (example: git fetch, git push ...)

Remove the passphrase from an existing key

ssh-keygen -p
  1. It will ask the key location
  2. It will ask the old passphrase
  3. It will ask the new one (empty for no passphrase)

Check ssh access to a server

After having uploaded your public key to a service, check if that new connection works

# replace by your server (here global gitlab)
ssh -T [email protected]
# Then you ssh password is asked, Then you will receive a welcome message

Gitlab

Add your public key to your gitlab account

  1. Go to the itlab webpage
  2. Go to your profile menu top right and select Preferences
  3. In the User Settings sidebar, select SSH keys
  4. Copy your public key into the big text zone and click on the Add key button

Git

Add your ssh private key to your git

You must add your private key to the local git repository

git config core.sshCommand 'ssh -i ~/.ssh/id_rsa'

You can verify that the private key is in the git config with the command

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