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. ...

Get GitLab Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.