Setup SSH Public Key authentication to login to a target

  • On your host machine, use ssh-keygen to generate an SSH key pair
    • ssh-keygen -t rsa
      • Follow the prompts
        • choose the <location> for the file
        • choose a <keyname> e.g. id_rsa_name_of_target
        • set a strong password to unlock the private key
        • default key-length is 2048-bits (don’t change if you do not understand what you are doing)
        • at the end of this process you will have a private/public keyfile <keyname> and a separate file with only the public key <keyname.pub>
      • N.B the private must never ever leave the host
      • Comprehensive information can be found at the link below information can be found at https://www.ssh.com/ssh/keygen/
  • Output the public key  in the format required by the target e.g. Open Media Vault v2.0 needs the public key to be output in RFC 4716 format
    • ssh-keygen -e -f </location/keyname>
  • Copy the public key to the target.
  • Use the host machine where the private key is stored to login to target server
    • ssh <user>@<IP address of target> -i <location>/<keyname>