Create key:
ssh-keygen -t rsa -b 4096 -C "Key description"
and choose the key file name and location.
To login using this key use this command:
ssh username@1.2.3.4 -i /path-to-key-file-no-pub
To add a user in the target system:
adduser username
To add the user to sudoers use:
usermod -aG sudo username
To test:
su - username
and enter a sudo command.
To add the public key in the user home, create this file and paste in it the public key with this commands:
mkdir .ssh
nano .ssh/authorized_keys
and change the file permissions:
chmod 600 .ssh/authorized_keys