There are just 3 simple steps to start pushing some stuff to gitlab using SSH
- Sign-up or request new account
- Generate SSH keys
- Upload SSH key to GitLab
- Update ~/.ssh/config for non-standart SSH port
Sign-up form is available at URL
sign-up may be disabled by evil paranoid admins Request account as described below
Send a request via transport
to contact
***Update with correct conatnct info ***
- Generate SSH keys using
ssh-keygen
(skip this step if you want to use existing SSH keys) - Post content of id_rsa.pub to https://gitlab.example.com/profile/keys
Avoid using Putty's puttygen utility to generate keys unless you can export keys in correct format
TL;DR; Putty's keys format is incompartible (see below for details)
SSH port may be changed from 22 to some other value due to security reasons. You need to specify correct SSH port either in ~/.ssh/config file (globally) or specified it in URL (for each git repo you are going to push into)
Add or update section in ~/.ssh/config
Host gitlab.example.com
User git
Port 2222
For example GIT repo is available as [email protected]:foo/bar
and the SSH port is 2222
An alternate URL is ssh://[email protected]:2222/foo/bar
You may generate separate shs keys to access each gitlab server.
-
generate ssh keys with non-standard name on first question of
ssh-keygen
. Leave passphrase empty by hitting Enter.#> ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/username/.ssh/id_rsa): /home/username/.ssh/id_rsa_gitlab_example Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/username/.ssh/id_rsa_gitlab_example. Your public key has been saved in /home/username/.ssh/id_rsa_gitlab_example.pub. The key fingerprint is: 69:64:64:71:64:69:64:6b:66:61:69:64:63:6c:69:70 username@localhost The key's randomart image is: +---[RSA 2048]----+ | | | | | (\___/) | | (='.'=) | | (")_(") | | | | | | | | | +-----------------+
-
Post content of public key
/home/username/.ssh/id_rsa_gitlab_example.pub
to GitLab as described above. -
Update
~/.ssh/config
with IdentityFile (note that it must point to private key, not public)Host gitlab.example.com User git Port 2222 IdentityFile ~/.ssh/id_rsa_gitlab_example # <--- there is not .pub at the end
you may check if keys are accepted using ssh
#> ssh -p 2222 -I /path/to/private/key [email protected]
PTY allocation request failed on channel 0
Welcome to GitLab, Luke Skywalker!
Connection to gitlab.example.com closed.
#>_
The message above states the SSH connection is established and the user is authenticated.
Note that GitLab welcomes the actial owner of SSH key, not a generic git
user
You don't get shell promt, just welcome message. If you are asked for git password you keys does not match.
Git client uses OpenSSL/OpenSSH (and keys in PKCS#8 PEM
) so Putty's key format ('traditional' PEM) is incompatible.
You may use openssl rsa
to convert but it better to use OpenSSH to generate keys i first place
More details here
You can export private key in OpenSSH format using puttygen's menu Conversations
->Export OpenSSH key
This text is available under terms of WTFPL