Setting Up SSH on Linux

Learn how to set up secure SSH access on your Linux server with advanced configuration options.

  1. Install OpenSSH server:
sudo apt install openssh-server
  1. Configure SSH with enhanced security:
sudo nano /etc/ssh/sshd_config

Set these recommended options:

PermitRootLogin no
PasswordAuthentication no
AllowUsers yourusername
  1. Generate SSH keys:
ssh-keygen -t ed25519 -C "[email protected]"
  1. Restart SSH service:
sudo systemctl restart ssh
  1. Test connection with key-based authentication:
ssh -i ~/.ssh/id_ed25519 user@your-server-ip

Additional security measures:

  • Use fail2ban to prevent brute force attacks
  • Implement two-factor authentication
  • Regularly update SSH packages
  • Monitor SSH logs for suspicious activity

Read more: OpenSSH Documentation