Docs

Generate a new SSH key pair

Generate a new SSH key pair

Before creating an SSH key pair, make sure to understand the different types of keys.
To create a new SSH key pair:

  1. Open a terminal on Linux or macOS
  2. Generate a new RSA SSH key pair:
    ssh-keygen -t rsa -b 4096 -C "[email protected]"
    Or, if you want to use ED25519:
    ssh-keygen -t ed25519 -C "[email protected]"
    he -C flag adds a comment in the key in case you have multiple of them and want to tell which is which. It is optional.
  3. Next, you will be prompted to input a file path to save your SSH key pair to. If you don’t already have an SSH key pair and aren’t generating a deploy key, use the suggested path by pressingEnter. Using the suggested path will normally allow your SSH client to automatically use the SSH key pair with no additional configuration. If you already have an SSH key pair with the suggested file path, you will need to input a new file path and declare what host this SSH key pair will be used for in your ~/.ssh/config file.
  4. Once the path is decided, you will be prompted to input a password to secure your new SSH key pair. It’s a best practice to use a password, but it’s not required and you can skip creating it by pressingEnter twice. If, in any case, you want to add or change the password of your SSH key pair, you can use the -p flag:
    ssh-keygen -p -f [keyname]