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 ~/.sshchmod 600 ~/.ssh/authorized_keys
- Optional: disable password authentication in
/etc/ssh/sshd_config:Then reload:PasswordAuthentication noChallengeResponseAuthentication noUsePAM yessudo systemctl reload ssh