Setup Git for using GitLab (including SSH key) - Linux

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today i'll show you how to generate and configure your ssh key for gitlab if you're using linux for windows or macos the process is similar but i'll link you to a different tutorial for that let's get started [Music] for this tutorial i'll be using linux mint but for any other linux distribution the steps should be pretty similar but just in case you have any issues leave me a comment in the section below and i will add more details to this video description so let's get started the first step that i want you to do is to open a terminal window and simply type in the command git or git dash version to see what's happening so in my case kit is not installed and i'm even suggested here which command i should enter in order to properly install gate so this is exactly what i will do i'm gonna be asked for my password i'm gonna confirm that i want to install get and probably in just a few seconds the entire installation process will be over okay so if i type in the exact same command once again i'll see now that git has been properly installed now since this is your first time installing it it's very important that you configure a few things and one of the things you need to configure is your username or the name that will be used when you're committing and your email so the configuration that i'll be doing here is also available for you to copy paste from the video description just adapt as needed recommend this git config and this will be a global configuration and first of all i'm setting the username typically it is your first name and your last name so this has been set and pretty similar you'll also have your user email now this will ensure that when you're trying to commit something it will work without any issues the next step is to go inside gitlab and try to clone an existing repository you're probably seeing this message here right on top this indicates that you don't have an ssh key but we'll get to that in a second so when you're cloning a repository you first have to get the address so by clicking this clone button two options will be available now one of them is cloning over https and when you're doing that you'll be asked all the time for your username and password now this is something that we want to avoid we want to clone with ssh and you're probably wondering what is ssh ssh is a way to authenticate without exposing your username and password ssh stands for secure shell and is essentially a cryptographic protocol based on the concept of public private keys we'll generate this combination of a public private key in just a second we're using ssh with git because it is much easier than typing your username and password all the time and it's typically also more secure so what i'm going to do next is simply i'm going to try to clone this repository by using ssh so this is why i'm copying this url here so i'm going back to the terminal i'll write git clone because we're trying to clone this and i'm going to simply go ahead and paste it i'm going to have this address here first time when you're connecting to a server you will get this information regarding the authenticity of the server so it's absolutely fine for the first time to click yes and this shouldn't happen again and the next order that you will get immediately is permission denied public key lava could not read from remote repository so this is the problem that we're trying to solve so we don't have permission and definitely in this case we weren't asked for any username and password so the next step that we need to take is to generate this ssh key and we're going to use a tool for doing that that tool is probably already available on your computer so let's give it a try so i'm going to write a command ssh dash keygen and this is practically like a wizard that will take us through the process of generating this public private rsa rsa is the encryption standard that's being used it's a very secure encryption standard and the first step is we are being asked where to save this key so essentially this will be your private key by default it will be created in a user folder and the subfolder will be dot ssh i highly recommend that you keep it under this name and just hit enter to move on to the next option the next option is to enter a passphrase the idea with the passphrase is to protect your private key just in case someone gets to this file and i highly suggest that you enter passphrase because anyone getting your private key somehow without this additional security measure you will not be able to use it so highly highly recommended don't skip this step and as you will see here in mint linux this will be much easier to remember this password without you having to type it all the time so i'm going to go ahead and enter password here don't worry if it doesn't show up it's just a normal thing how this is going over the terminal now after entering this passphrase two things have happened so first of all you have this identification file here so this line this is telling you that your private key and it's important to remember your private key is this id underscore rsa saved in the dot ssh folder and then your public key has been saved in the same folder it is just called differently it's called id underscore rsa.pub it's very important to remember that you never want to share with anyone your private key but all the time when you're trying to connect to a server your server needs to know your public key so it's always fine to share your public key with anyone you can even post it on the internet it doesn't contain any secrets this is how using public private keys works you don't have any secrets in your public key the server will be able to tell if it's you that is trying to authenticate so very very strong way to do this and none of this information is actually leaving your computer you're not sending any passwords over the wire or something like that so in order to communicate this public key to gitlab we need to get the contents of this file so you can either go directly in this folder or you can simply copy the path that you see here and we're going to simply use a command cap this will give us the content of the file and we're going to specify the path where this is and this is how your public key looks like so all i have to do is simply copy the entire string as you see it here and in your gitlab account you either click on this button add ssh key or in case you don't see it you can click on your profile go to settings and from this menu on the left hand side you have to select ssh keys so the next step is simply pasting it here you can even give it a name so that you know why you have created it and essentially it never expires so simply go ahead and click on add key so now your key has been added if you go back to this page once again you'll be able to see here on the lower part of the screens all your ssh keys so essentially for different systems you can have different keys that are added and you're still identified as the same user just in case your key it's compromised or you no longer have it you can easily revoke any access to it by deleting it from here and no access will be permitted anymore so going back to the terminal let's see if it works now so the command will be still the same git clone and that will be the address that we're trying to clone and only now you will be asked for your private key so i'm going to enter my private key and what's important here so that you don't guest ask all the time to enter your private key is to automatically unlock this key whenever you're logged in so if you click this and you have a secure linux password as a user when you're entering your system and also your home folder is encrypted this is a very good thing to do because it will save you a lot of time now concept is pretty similar on mac os in order to save this in your keychain on linux again you'll have this possibility of saving this information here you don't have to enter it again it's just important that you store it somewhere securely so that in case you need to enter it once again you know what it is but as you've seen if something happens and you don't know this password anymore you can go the entire process once again and generate a new key pair of a public private key so i'm going to click here on unlock so as you seen the clone process worked without any issues so if i'm going inside the project itself you can see it is a git project i can run a bit pull command to see how it is working and you can see i have absolutely no issues i hope that everything worked as i've shown you in the tutorial and that you can now start using git and gitlab i would really appreciate if you would give this video a thumbs up and consider subscribing see you next time guys you
Info
Channel: Valentin Despa
Views: 9,909
Rating: 4.945652 out of 5
Keywords: new gitlab ssh key for profile, gitlab tutorials for beginners, git for Linux, using ssh on Linux, setup git path in Linux, gitlab tutorial, gitlab ce tutorial, Linux, git installation on Linux, how to install git on Linux, ssh keys gitlab Linux, how to create ssh key in gitlab, Linux ssh, gitlab for projects, Linux openssh, gitlab for Linux, gitlab install Linux, gitlab install on Linux, how to install gitlab runner on Linux
Id: iXuIp5uNnLk
Channel Id: undefined
Length: 11min 27sec (687 seconds)
Published: Sat Feb 06 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.