# local
# Generate an SSH key pair.
ssh-keygen -t rsa -b 4096 -C "your_name@your.domain" -f /path/to/new_key_pair.pem
# remote
# Add a new user.
sudo adduser new_user
sudo su - new_user # Log in as the new user.
# remote (new_user)
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
cat >> .ssh/authorized_keys
# Here, paste "/path/to/your_key_pair.pem.pub", Enter (for a new line), Ctrl+D (to exit cat)
exit
# local
ssh -i /path/to/new_key_pair.pem new_user@public_dns_name_of_EC2_Linux_instance