SSH Basics
Table of contents
Create a key pair
Base command structure is as follows:
ssh-keygen -t <algorithm> -C <comments>
Then follow the prompt.
Do not use ssh-rsa
algorithm as it is rejected by modern OpenSSH servers. Use rsa-sha2-256
, rsa-sha2-512
, ed25519
, etc. instead.
Copy public key to remote server
The following command will copy your public key to remote server’s authorized_keys
file.
It will also check for duplicate keys and will not add the key if it is.
ssh-copy-id -i <path_to_pub_key> <remote_host>
References: