I manage a bunch of internal servers and for those that aren’t part of the wider web I like to use key pairs to speed up my sign ins and maintenance.
Key-based authentication is the most secure mode of authentication usable with OpenSSH. Key-based authentication has several advantages over password authentication, for example the key values are significantly more difficult to brute-force, or guess than plain passwords, provided an ample key length.
Key-based authentication uses two keys, one “public” key that anyone is allowed to see, and another “private” key that only the owner is allowed to see. To securely communicate using key-based authentication, one needs to create a key pair, securely store the private key on the computer one wants to log in from, and store the public key on the computer one wants to log in to.
Host – this is the primary computer you sign in from.
If you are going to be using a specific user on both computers, make sure they are setup on both the host AND the target.
Use this command to generate a strong key to use for connecting to the target. Leave all prompts blank when generating it.