Docs / Security / Hardening SSH: Disabling Root and Password Auth

Hardening SSH: Disabling Root and Password Auth

By Admin · Mar 15, 2026 · Updated Apr 24, 2026 · 7 views · 2 min read

This guide covers how to set up and configure ssh on a Linux VPS. Whether you're running a production environment or a development setup, these instructions will help you get started quickly and securely.

Prerequisites

  • Basic familiarity with the Linux command line
  • Current system packages (run apt update && apt upgrade)
  • Root or sudo access to the server

Installation and Configuration

The default configuration works well for development environments, but production servers require additional tuning. Pay particular attention to connection limits, timeout values, and logging settings.


# Install and configure ssh
sudo apt update && sudo apt install -y ssh

# Backup existing config
sudo cp /etc/ssh/ssh.conf /etc/ssh/ssh.conf.bak

# Edit configuration
sudo nano /etc/ssh/ssh.conf

These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.

Creating Security Rules

It's recommended to test this configuration in a staging environment before deploying to production. This helps identify potential compatibility issues and allows you to benchmark performance differences.


# Check security status
sudo ssh --check
sudo systemctl status ssh

# View logs for security events
sudo journalctl -u ssh --since "1 hour ago"
sudo tail -f /var/log/ssh.log

These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.

Important Notes

It's recommended to test this configuration in a staging environment before deploying to production. This helps identify potential compatibility issues and allows you to benchmark performance differences.

  • Maintain runbooks for common operations
  • Use version control for configuration files
  • Test disaster recovery procedures regularly

Common Issues and Solutions

  • Connection timeout: Verify your firewall rules allow traffic on the required ports. Use ss -tlnp to confirm the service is listening on the expected port.
  • Slow performance: Check for disk I/O bottlenecks with iostat -x 1 and network issues with mtr. Review application logs for slow queries or requests.

Wrapping Up

Following this guide, your ssh setup should be production-ready. Keep an eye on resource usage as your traffic grows and don't forget to test your backup and recovery procedures periodically.

Was this article helpful?