Generate SSH Key:
- ssh-keygen -t rsa -C "Comment for key"
Add it to gitlab:
- cat ~/.ssh/id_rsa.pub (copy all output)
- Open web browser, go to: Gitlab > User Settings > SSH Keys
- Paste copied output in the SSH key section
Test connection:
- ssh -T git@gilab.domain.com (can use private url)
Do some git stuff:
- git clone something
#For example, for ED25519:
> ssh-keygen -t ed25519 -C "<comment>"
#For 2048-bit RSA:
> ssh-keygen -t rsa -b 2048 -C "<comment>"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/user/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
> eval $(ssh-agent -s)
> ssh-add <directory to private SSH key>
Ssh config
# GitLab.com
Host gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitlab_com_rsa
# Private GitLab instance
Host gitlab.company.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/example_com_rsa