Linux SSH Configuration & Hardening
Generate Ed25519 SSH keypairs, configure ~/.ssh/config, manage authorized_keys, and harden sshd_config against unauthorized access.
1. Generating Modern SSH Keypairs (Ed25519)
[!NOTE] Modern cryptographic standards recommend Ed25519 over legacy RSA keys because Ed25519 offers stronger security with faster signature computation and compact key lengths.
# Generate Ed25519 keypair with an email label
ssh-keygen -t ed25519 -C "admin@example.com" -f ~/.ssh/id_ed25519This produces two files:
~/.ssh/id_ed25519: Private Key (Never share, permissions600).~/.ssh/id_ed25519.pub: Public Key (Copied to remote servers, permissions644).
2. Copying Public Key to Remote Server
# Automated copy to remote server's ~/.ssh/authorized_keys
ssh-copy-id -i ~/.ssh/id_ed25519.pub deployer@192.0.2.103. Simplifying Connections with ~/.ssh/config
Configure aliases and key mappings so you can connect via ssh production:
# ~/.ssh/config
Host production
HostName 192.0.2.10
User deployer
Port 22
IdentityFile ~/.ssh/id_ed25519
ServerAliveInterval 60Connect:
ssh production4. Server-Side SSH Hardening (/etc/ssh/sshd_config)
To protect your Linux server from automated brute-force attacks:
# /etc/ssh/sshd_config
# Disable root direct SSH login
PermitRootLogin no
# Disable insecure password authentication (Keys ONLY)
PasswordAuthentication no
PermitEmptyPasswords no
# Use modern cryptographic algorithms
PubkeyAuthentication yesTest syntax and restart SSH daemon:
sudo sshd -t && sudo systemctl restart sshdLinux Logs & journalctl Troubleshooting
Inspect Linux system logs, query systemd services with journalctl, filter by time and priority, and manage logrotate.
Linux Environment Variables
Configure system-wide and user-level environment variables, PATH manipulation, and shell persistence (.bashrc, /etc/environment).