In the previous post (here) we created a SSH key pair.
Now we're gonna use the generated key pair to communicate with the Gitlab server.
Requirements:
You should already have created a key pair as mentioned (here)
Copying the key into the system clipboard
Follow the below steps:
Open the ~/.ssh/id_ed25519.pub file with your favorite text editor (i.e. xed, gedit, etc...)
Select with your mouse all the content of the file
Right click, and select "copy".
The content of the file is copied in to the system clipboard.
Adding your public key to the Gitlab server:
Open your web browser and Sign in to Gitlab.com.
On the left sidebar, select your avatar.
Select Edit profile
On the left sidebar, select SSH Keys.
Select Add new key.
In the Key box, paste the contents of your public key. If you manually copied the key, make sure you copy the entire key, which starts with ssh-rsa, ssh-dss, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-ed25519, sk-ecdsa-sha2-nistp256@openssh.com, or sk-ssh-ed25519@openssh.com, and may end with a comment.
In the Title box, type a description, like Work Laptop or Home Workstation.
Optional. Select the Usage type of the key. It can be used either for Authentication or Signing or both. Authentication & Signing is the default value.
Optional. Update Expiration date to modify the default expiration date.
Administrators can view expiration dates and use them for guidance when deleting keys.
GitLab checks all SSH keys at 01:00 AM UTC every day. It emails an expiration notice for all SSH keys that are scheduled to expire seven days from now.
GitLab checks all SSH keys at 02:00 AM UTC every day. It emails an expiration notice for all SSH keys that expire on the current date.
Select Add key.
Communicate with the Gitlab server using the key pair
Now that your public key is uploaded to the Gitlab server, you can communicate with it by using ssh.
Use the standard git commands but instead of the http address of your repo use the following syntax:
git clone git@gitlab.com:YourGitUserName/YourRepositoryName
i.e. if your repository is called "mydotfiles" and if your gitlab username is johndoe type:
git clone git@gitlab.com:johndoe/mydotfiles
Notes:
If you sign in to the server for the first time you're asked to confirm the IP for fingerprinting.
Select Y (yes)
If you need to pull, push, add, commit, or perform any other operation replace the above keyword with the required one.
If you have set up a shell alias for git, you can use that alias instead of the command 'git'.
Comments