ssh-keygen
- You will be asked the location to store the ssh keys (default : ~/.ssh/id_rsa)
- You will be asked the ssh passphrase 2 times
- Then the keys will be generated (public: id_rsa.pub | private: id_rsa)
- 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 ...)
ssh-keygen -p
- It will ask the key location
- It will ask the old passphrase
- It will ask the new one (empty for no passphrase)
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
- Go to the itlab webpage
- Go to your profile menu top right and select
Preferences
- In the
User Settings
sidebar, selectSSH keys
- Copy your public key into the big text zone and click on the
Add key
button
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