ssh-keygen -t KEY-TYPE -C "COMMENT"
The KEY-TYPE can be either:
- RSA (Which is the DEFAULT)
- ECDSA
- DSA
- ED25519
- XMMS
Now while creating an SSH-Key the system will ask you where to store your key [If you do not enter a location then. it simply saves in the DEFAULT-LOCATION which is .ssh & if there was a key already present in the specified locations then the key will be OVERWRITTEN with the new one]
When creating/generating your SSH-Keys, you will most probably be asked to provide a password for extra security; please consider creating a password if you truly wish to protect your SSH-Keys.
Now you simply copy the PUBLIC-KEY part of the SSH-Key which is indicated by the ".pub" file-extension into a file called "authorized_keys" located in the Remote-Server's ".ssh" folder [It is also the same location where SSH-Keys are usually stored PERIOD]. Now the easiest way of doing it would be via a command:-
ssh-copy-id -i PUBLIC_KEY-LOCATION REMOTE-SERVER
This will automate the otherwise manual process of adding the keys [ESPECIALLY, if you had to work with multiple SSH-Keys] in a line-by-line fashion in that previously-mentioned file on the remote-server. Now you can simply connect to your remote-servers via SSH without using a password [Eventhough the password can be used as backup]