Git Lab Documentation
What would you like to see added?
When logging into GitLab via SSH, you're generally not logging into the web interface of GitLab itself but rather interacting with the Git repositories hosted on GitLab. SSH is used to securely push, pull, and otherwise manipulate your Git repositories. Below are the general steps to log into GitLab using SSH:
Prerequisites
- Git installed on your local machine.
- A GitLab account.
Steps
-
Generate SSH Key Pair: If you don't already have an SSH key pair, you can generate one using the following command:
ssh-keygen -t ed25519 -C "[email protected]"-
-t ed25519specifies the type of key to create. -
-C "[email protected]"provides a label or comment for the key.
-
-
Add SSH Key to ssh-agent: Make sure ssh-agent is running, and add your SSH key.
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519-
eval "$(ssh-agent -s)"starts the ssh-agent in the background. -
ssh-add ~/.ssh/id_ed25519adds the SSH key to the ssh-agent.
-
-
Copy Public Key: You can display your public key with
cat ~/.ssh/id_ed25519.pub, then copy it to your clipboard. -
Add SSH Key to GitLab
- Go to GitLab and log in.
- Navigate to "User Settings" -> "SSH Keys".
- Paste your copied public key into the "Key" field and save.
-
Test Connection: You can then test your SSH key pair connection to GitLab with the following command:
ssh -T [email protected]- If successful, you will see a message like "Welcome to GitLab, @username!"
-
Clone Repository: Now you can clone a Git repository from GitLab using SSH.
git clone [email protected]:username/repository.git- Replace
usernameandrepositorywith the appropriate values.
- Replace
And that's it! You've successfully logged into GitLab using SSH for Git operations. Note that these steps are tailored for a Unix-like system such as Linux or macOS. The steps may vary for Windows.