• About Us
  • Disclaimer
  • Indeks
Kebumen Update
No Result
View All Result
  • Web Hosting and Server Management
  • Monitoring & Maintenance
  • Security & Hardening
  • Panels & Tools
  • Cloud & DevOps
  • Tech
  • Web Hosting and Server Management
  • Monitoring & Maintenance
  • Security & Hardening
  • Panels & Tools
  • Cloud & DevOps
  • Tech
No Result
View All Result
Kebumen Update
No Result
View All Result
Home Security & Hardening

SSH Hardening: Disable Root Login & Use Key Authentication

awbsmed by awbsmed
April 12, 2025
in Security & Hardening
0
Securing SSH Access on Your Ubuntu Server // Step-by-Step Tutorial
ADVERTISEMENT

 

Securing your Linux server is paramount in today’s digital landscape. One of the most effective measures is hardening SSH (Secure Shell) access by disabling root login and implementing SSH key authentication. This approach minimizes potential attack vectors and enhances overall system security.​

READ ALSO

Installing Let’s Encrypt SSL on Your VPS (Free & Easy)

How to Secure Your Linux Server with UFW Firewall


A. Understanding the Risks of Root SSH Access

The root account has unrestricted access to all commands and files on a Linux system. Allowing direct SSH access to this account poses significant security risks:​

ADVERTISEMENT

A. Predictable Target: The username ‘root’ is common knowledge, making it a prime target for attackers.​

B. Brute-Force Vulnerability: Attackers can attempt to guess the root password, and if successful, gain full control over the system.​

C. Automated Attacks: Bots continuously scan networks for systems with SSH ports open, attempting to exploit them using common credentials.

By disabling root SSH access, you reduce the risk of unauthorized system-wide access.


B. Creating a Non-Root User with Sudo Privileges

Before disabling root login, ensure you have a non-root user with administrative privileges:

bash
sudo adduser newuser
sudo usermod -aG sudo newuser

Replace newuser with your desired username. This user can perform administrative tasks using sudo.​


C. Disabling Root Login Over SSH

To prevent root login via SSH:

  1. Edit the SSH Configuration File:

bash
sudo nano /etc/ssh/sshd_config
  1. Modify the PermitRootLogin Directive:

Locate the line:​

bash
#PermitRootLogin yes

Change it to:​

bash
PermitRootLogin no

Ensure the line is uncommented (remove the # if present).​

  1. Restart the SSH Service:

bash
sudo systemctl restart sshd

This change will deny SSH access to the root account.​


D. Implementing SSH Key Authentication

SSH keys provide a more secure authentication method than passwords.

  1. Generate SSH Key Pair on Client Machine:

bash
ssh-keygen -t rsa -b 4096

Press Enter to accept the default file location and set a passphrase if desired.​

  1. Copy Public Key to Server:

bash
ssh-copy-id newuser@server_ip

Replace newuser with your non-root username and server_ip with your server’s IP address.​

  1. Disable Password Authentication (Optional but Recommended):

On the server, edit the SSH configuration:​

bash
sudo nano /etc/ssh/sshd_config

Set the following directives:​

bash
PasswordAuthentication no
ChallengeResponseAuthentication no

Restart the SSH service:​

bash
sudo systemctl restart sshd

This ensures only SSH key-based logins are permitted.​


E. Additional SSH Hardening Measures

A. Limit User Access:

Restrict SSH access to specific users by adding the following line to /etc/ssh/sshd_config:​

bash
AllowUsers newuser

Restart SSH to apply changes.​

B. Change Default SSH Port:

Changing the default SSH port (22) can reduce automated attacks:

  1. Edit SSH Configuration:

bash
sudo nano /etc/ssh/sshd_config

Modify the Port directive:​

bash
Port 2222

Replace 2222 with your chosen port number.​

  1. Update Firewall Rules:

Allow the new SSH port through your firewall. For UFW:​

bash
sudo ufw allow 2222/tcp
  1. Restart SSH Service:

bash
sudo systemctl restart sshd

C. Enable SSH Logging:

Monitor SSH access attempts by reviewing logs:​

bash
sudo tail -f /var/log/auth.log

Regularly check logs for suspicious activity.​


Hardening SSH by disabling root login and implementing SSH key authentication significantly enhances your server’s security posture. By following these best practices, you reduce the risk of unauthorized access and protect sensitive data. Regularly review and update your security measures to stay ahead of potential threats.​

Tags: disable root loginlinux server hardeningsecure remote accessSSH best practicesSSH configurationssh key authenticationSSH security
ADVERTISEMENT

Related Posts

How to install Let's Encrypt SSL using DirectAdmin | LinuxCloudVPS Blog
Security & Hardening

Installing Let’s Encrypt SSL on Your VPS (Free & Easy)

April 12, 2025
How to Manage a Firewall on Linux (UFW) - This will secure your network.
Security & Hardening

How to Secure Your Linux Server with UFW Firewall

April 12, 2025
Top 10 Best Practices for Secure Software Development
Security & Hardening

10 Essential Server Security Practices You Shouldn’t Ignore

April 12, 2025
Next Post
How to install Let's Encrypt SSL using DirectAdmin | LinuxCloudVPS Blog

Installing Let’s Encrypt SSL on Your VPS (Free & Easy)

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Hybrid Cloud Reigns: The Smart IT Strategy

Hybrid Cloud Reigns: The Smart IT Strategy

by Salsabilla Yasmeen Yunanta
June 26, 2025
0

In the intricate landscape of modern enterprise IT, the concept of a singular, all-encompassing solution is increasingly a relic of...

NVMe Storage Transforms: The Data Speed Revolution

NVMe Storage Transforms: The Data Speed Revolution

by Salsabilla Yasmeen Yunanta
June 26, 2025
0

In the lightning-fast world of modern computing, where every millisecond counts, the storage subsystem has long been a bottleneck. Traditional...

Best Server Providers for 2025 - Server

Top Server Providers for 2025

by awbsmed
May 17, 2025
0

In the rapidly evolving digital landscape of 2025, selecting the right server provider is crucial for businesses and individuals alike....

Edge Computing Transforms Real-Time Data Processing

Edge Computing Transforms Real-Time Data Processing

by awbsmed
May 16, 2025
0

In an era defined by instantaneous insights and ultra‑low latencies, edge computing has emerged as a transformative force reshaping how...

Kebumen Update

KebumenUpdate.com diterbitkan oleh PT BUMI MEDIA PUBLISHING dengan sertifikat pendirian Kementerian Hukum dan Hak Asasi Manusia Republik Indonesia Nomor: AHU-012340.AH.01.30.Tahun 2022

  • About Us
  • Editor
  • Code of Ethics
  • Privacy Policy
  • Cyber Media Guidelines

Copyright © 2025 Kebumen Update. All Right Reserved

No Result
View All Result
  • Homepages
    • Home Page 1
    • Home Page 2
  • Tech

Copyright © 2025 Kebumen Update. All Right Reserved