Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Create a New SSH Public and Private Key Set


    Learn how to generate an SSH private and public key set. We'll also cover what permissions are set on the .ssh folder, as well as what each of the id_rsa and id_rsa.pub keys are and what they do.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: SSH keys are used as a very secure method for server authentication. Keys can be easily generated by running the ssh-keygen command. If you then hit enter three times in succession, the keys will be created. Note that this is the most common way of generating SSH keys, and will place your keys in their default locations and create them without a passphrase.

    SSH keys created are placed within a .ssh directory within your home directory. If you view the contents of this folder, you will see the private and public keys. The private key is id_rsa, and the public key is id_rsa.pub.

    Note the permissions set on the folder and keys. The .ssh folder and private key are both only readable and writable by the current user, while the public key is readable by any user on the system.

    Let's check out the private key, id_rsa. You must never give out or display the contents of your private key with anyone. This is your secret, the equivalent of a password. Now look at the public key, id_rsa.pub. Feel free to share your public key with anyone, or any server which you would like to authenticate with.

    You may also edit the last part of your public key after the space. This is treated as a comment to document which public key this is, and can be helpful when keeping track of many servers using different keys.