The importance of ssh keys is a topic that day by day helps me realize how much time I save or how lazy I am. Believe me, nobody likes to enter their passwords and username at least ten times a day. That is why I want to explain how to configure your own ssh keys so that you can clone repositories without authenticating or connecting to a remote computer only by indicating a previously configured nickname.
4G has come a long way and changed the world of telecommunications for the better. Learn the history of 4G here.
For this case, I will not explain how they work but how to configure them.
The first step is to generate the key that we will use later. Our public key can be generated in the following way.
In this case, we would already be generating our keys to be able to use.
The next thing we will do is go to the following directory and copy the file.
That file is the one that contains our public key. If you use Linux, one way to copy them is
After that, we could enter GitLab and copy our keys. In this case, we will show how to connect to a computer remotely with our passwords and avoid the annoying message of authenticating ourselves repeatedly when we want to access it.
The usual way to access a remote computer is with the user and the IP. We will use as an example a small team that I have.
Assuming that the remote computer has the standard ssh port enabled (port 22). Otherwise, it would be necessary to find out what position is exposed and add the flag to the statement
Following that, it will ask us for a password to access that computer. We enter the password and go to the .ssh directory to add our previously copied public key.
In this directory, we will find a file called authorized_keys. If it does not exist, we create it and in it is where we will paste our key.
After having our password on our remote computer that we will access without our authentication, configuring it on our machine is the last step. That is why we will leave the remote computer and go to our computer’s .ssh directory and enter to edit the config file.
Then we will have to copy something like this:
To understand a bit more:
- Host will be the alias with which we enter our remote computer.
- Hostname is the public IP of our remote computer.
- Port is the port with which the equipment is accessed.
- User is the user with which the remote computer is entered.
- IdentityFile is our generated ssh key. It will be verified with the one we have copied in the authorized_keys of our remote computer.
Finally, once these values are set, we will save the file, and we will be able to access our remote computer only by indicating the Host.
As you can see, you can enter without problems and save the annoying hassle of entering the username and password again and again or remembering the remote computer’s IP.
4G has come a long way and changed the world of telecommunications for the better. Learn the history of 4G here.