官术网_书友最值得收藏!

Generating your SSH key on Unix-like systems

Generating an SSH key on Linux and OS X is easy; they come with a built-in tool to do this, called ssh-keygen.

How to do it…

In the following steps, we will create an SSH key for your Unix system:

  1. First, we are going to check whether you have any SSH keys present. Open your terminal and enter the following command:
    $ ls ~/.ssh
    
  2. If you have a file named id_rsa.pub or id_dsa.pub, you can skip this recipe.
  3. To generate a new SSH key, you need to open your terminal and enter the following command:
    $ ssh-keygen -t rsa -C "Comment for key"
    

    The comment can be anything you want; it makes it easier for you to see which key it is when you open the key file.

  4. Now, we get to the question of what you want to name your key. Just press Enter.
  5. You will be asked to enter a passphrase. Enter it, and be sure to choose a strong password.

    You should see the following screenshot:

Your SSH key is now generated.

How it works…

We just created our personal SSH key: one key is the id_rsa file and one is the id_rsa.pub file. Whenever you need to provide your public SSH key, make sure that you use the id_rsa.pub file. The other file should remain safely on your machine, as this is the private key. If you feel this key has been compromised, you should create a new SSH key and revoke the SSH key on all the systems you used it for.

The SSH key helps you to authorize yourself in your GitLab instance without having to use a username and password.

One thing that is important while creating your SSH key is to remember to enter a passphrase. We use an SSH key because we believe that passwords are less secure, so you might think that if you're using an SSH key, you will be safe. This is not entirely true. When a person takes control over your private key, they have access to every system you have put your public key in. However, when you use a passphrase for your SSH key, not only do they have to steal your private key, but they also know the password that goes with it.

主站蜘蛛池模板: 读书| 甘德县| 浦县| 乌兰察布市| 张家港市| 南阳市| 宝山区| 巴林左旗| 淮阳县| 舞阳县| 永兴县| 密山市| 土默特左旗| 长兴县| 吕梁市| 芷江| 威远县| 海盐县| 和田县| 汝南县| 灯塔市| 贺兰县| 无极县| 潼南县| 安溪县| 昌吉市| 宁津县| 澄城县| 昌乐县| 唐山市| 蒙城县| 泾源县| 密云县| 德庆县| 黄骅市| 洪湖市| 华阴市| 会理县| 富平县| 正宁县| 乌兰浩特市|