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

  • GitLab Cookbook
  • Jeroen van Baarsen
  • 388字
  • 2021-08-05 16:55:05

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.

主站蜘蛛池模板: 镇安县| 房产| 凤城市| 子长县| 麻江县| 远安县| 分宜县| 隆化县| 四川省| 肥西县| 西昌市| 会东县| 盐亭县| 乐至县| 巴彦淖尔市| 荃湾区| 沂水县| 乐至县| 永吉县| 新巴尔虎右旗| 东城区| 库伦旗| 延吉市| 南漳县| 如东县| 宁晋县| 潢川县| 赤城县| 会理县| 绥德县| 巴林左旗| 镇沅| 新兴县| 苏尼特右旗| 石狮市| 商水县| 班戈县| 靖安县| 文化| 前郭尔| 交城县|