官方文档:https://docs.gitlab.com/ee/ssh/
Generating a new SSH key pair
To generate a new SSH key pair, use the following command:Git Bash on Windows / GNU/Linux / macOS:
ssh-keygen -t rsa -C "your.email@example.com" -b 4096
生成后的ssh key在~/.ssh中
If you want to change the password of your SSH key pair, you can use
ssh-keygen -p <keyname>
.Adding a SSH key to your GitLab account
add your public SSH key to GitLab.Navigate to the 'SSH Keys' tab in your 'Profile Settings'. Paste your key in the 'Key' section and give it a relevant 'Title'. If you manually copied your public SSH key make sure you copied the entire key starting with ssh-rsa
and ending with your email
Optionally you can test your setup by running ssh -T git@example.com
(replacing example.com
with your GitLab domain) and verifying that you receive a Welcome to GitLab
message.