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

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.

主站蜘蛛池模板: 舞阳县| 蒙山县| 合江县| 从江县| 乌鲁木齐县| 那坡县| 新河县| 科技| 霍州市| 新宁县| 锦州市| 东乌珠穆沁旗| 同心县| 山东| 美姑县| 汉沽区| 封开县| 邢台县| 莆田市| 博客| 舟曲县| 屏东县| 辽宁省| 称多县| 昭通市| 汉川市| 吉水县| 高密市| 墨江| 松原市| 宁陵县| 玉环县| 略阳县| 信丰县| 乌鲁木齐县| 汤阴县| 林周县| 双峰县| 巫山县| 广丰县| 金昌市|