SSH Key-Based Authentication
Configure SSH key auth on a Linux server.
Steps
- Generate a key on your local machine:
ssh-keygen -t ed25519 -C "your_email@example.com" - Copy the public key to the server:
ssh-copy-id <user>@<server>
# or manually append the public key to ~/.ssh/authorized_keys - Secure permissions:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys - Optional: disable password authentication in
/etc/ssh/sshd_config:Then reload:PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yessudo systemctl reload ssh