Abstract
To enhance the security of my cloud servers and Mac exposed to the public internet, I plan to replace all password-based authentication with SSH key-based authentication.
Method
1. Generate SSH Key Pair
You can easily generate an RSA 4096-bit key pair using a terminal on macOS, Linux, or Windows:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
After executing this command, you will get two files (by default in ~/.ssh/
):
id_rsa
: your private key (keep it safe!)id_rsa.pub
: your public key
2. Deploy the Public Key
To enable key-based login, append the public key to the authorized_keys
file on the target server:
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Make sure you're operating on the correct user's .ssh
folder on the server, not your local machine.
✅ Once you've done this, you should be able to log in to your server using your SSH key without a password.