Creating Key Pairs Using a Terminal (2024)

Generating SSH key pairs locally

  1. In a terminal, type the commandssh-keygen -t rsa, and press enter.
  • To save the key pair in other than the default directory of ~./ssh or with a different name, add the-fflag followed by the directory and key pair name (e.g. ~/Desktop/key).
  • When asked to enter file in which to save the key, press enter without typing in a name.
    • If a file name is supplied, the key pair will be saved in the terminal's current directory with the supplied name.
    • By default, keys are saved in the~/.sshdirectory with the namesid_rsa,id_rsa.pub.
  • Enter a password for the key pair, and press enter. You will be asked to retype the password for confirmation.
  • Upload thepublickey file (the one ending in.pub).
  • Logging in with SSH

    1. In a terminal, type the commandsshfollowed by the remote host name.
      • If your local machine account name is different from your login username, include the-lflag followed by your login username. This should go before the remote host name.
      • If the private key has a non-default name or directory, include the-iflag followed by the correct directory and name. This should go before the remote host name.
      • Your command might look like this:ssh -luserName-ipathToKey remoteHostName
    2. Press enter, and type the password associated with the key pair.
    Creating Key Pairs Using a Terminal (2024)
    Top Articles
    Latest Posts
    Article information

    Author: Rob Wisoky

    Last Updated:

    Views: 6071

    Rating: 4.8 / 5 (48 voted)

    Reviews: 95% of readers found this page helpful

    Author information

    Name: Rob Wisoky

    Birthday: 1994-09-30

    Address: 5789 Michel Vista, West Domenic, OR 80464-9452

    Phone: +97313824072371

    Job: Education Orchestrator

    Hobby: Lockpicking, Crocheting, Baton twirling, Video gaming, Jogging, Whittling, Model building

    Introduction: My name is Rob Wisoky, I am a smiling, helpful, encouraging, zealous, energetic, faithful, fantastic person who loves writing and wants to share my knowledge and understanding with you.