Check for Existing SSH Keys
You may already have an SSH key pair generated on your machine. To see whether you have SSH keys on the system, run the command:
ls -al ~/.ssh/id_*.pub
Generate SSH Key Pair
1. The first thing you need to do is generate an SSH key pair on the machine you are currently working on.
ssh-keygen -t rsa
Upload Public Key Using the ssh-copy-id or SFTP/SSH with Cat Command.
Option 1. Using the ssh-copy-id Command
Connect to the remote server and use the
ssh-copy-id command, The public key is then automatically copied into the .ssh/authorized_keys file.
Option 2. Using The sftp with cat command :
sftp> cd .ssh
sftp> put id_rsa.pub
Now login remote server :
cat id_rsa.pub >> authorized_keys
Option 3. Using SSH with cat command :
cat .ssh/id_rsa.pub | ssh email@example.com ‘cat >> .ssh/authorized_keys