• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

securitywing

Menu
  • About
  • Must Read
      • IIS Performance Boost
      • RFID Security
      • Web App Security Testing
      • How to Secure Home Network
      • Prevent Cross-Site Scripting Attacks
      • Renew Self-Signed Certificates
      • Penetration Testing Tools
      • VPN Concentrator
      • Forensic Investigation Tools
      • Digital Certificates
      • Cloud Security Issues
      • Advanced Evasion Prevention
      • Firewall Types
      • Tips to Prevent Data Exfiltration
      • Classified Info Handling
      • MySQL Security
      • Definition of 7 Types of Malware
      • VOIP Security
      • Why Antivirus Software Fails
      • 15 Network Security Vulnerabilities
      • Web App Security
      • IT Security Standards
      • Types of Virtualization
      • Android Security
      • Digital Signature
      • Advanced Malware Protection
    • Close
  • Consultancy
  • Contact

How to Disable Root Login Via SSH in Linux

by wing

Having the option of logging in to your server with SSH is essential for some web administrators, but logging in your server with root credentials via SSH is always unsafe. By the word root credentials, I mean that you should not remotely login with your server with root user name, rather use a less privileged user to login to your server and then use the “su” command to login as a root user.

So, the purpose of this post is to show you:

  • How to disable SSH with root username?
  • How to enable a normal user to login with SSH?
  • How to use root username after login with less privilege user name?

how to disable root user access via SSH in centos

Step 1

If you have already installed your Linux server, you need to make sure that you have created a user with password. For example, you want to create a username  chris, use the following commands:

#useradd chris
#passwd chris

Next type the password for the username chris.

When you type the above command a directory for the username will be created. If you want to delete a user name, type the following command:

#userdel –r username

Step 2

Now that you have a user other than the root user. So, you can safely deny the root user to access your server via SSH. To disable ssh root login you have to go to the following file:

Vi  /etc/ssh/sshd_config

sshd_config file

And then remove # from the line permitrootlogin. In vi editor, you need to press ”i” to enter in the insert mode. Then, use the backspace to remove the hash from the permitrootlogin and write no, instead of yes. After editing, your line should look like the following:

Permitrootlogin no

ssh root login disable i

To save the changes press “w”. use the ESC key to go back to the command mode in the vi editor. Finally, use type :quit to go back to our shell prompt.

Step 3

Now, restart sshd with the following command:

service sshd restart

The steps described above prevent Linux root login via SSH. Preventing SSH root login improves Linux security and considered top priority when IT security auditor assess Linux for security vulnerabilities.

Related Posts:

  • How to Create SSH key login with PuTTY in Windows
  • How to Extend Linux LVM by Adding a New Hard Disk
  • How to audit Linux CentOS Security with Lynis
  • Linux Security Basics

Filed Under: Network Security Tips Tagged With: linux, putty, root login, ssh

Primary Sidebar

CISSP Sample Test

Take a CISSP Sample Test

CISA IT governance Sample test



Twitter Follow @securitywing

Categories

  • AWS
  • containers
  • Internet Security and Safety
  • IS Audit
  • IT Security Exams
  • Network Security Tips
  • Off Track
  • Telecom
  • Tutorial

Pages

  • About
  • Best IT Security Certification Exam
  • CISA IT governance Sample test
  • CISA Sample Test
  • CISSP Sample Test Online
  • Consultancy
  • Contact

Popular Posts

  • 3 Steps to Install Miniku...
  • How to install a new Goda...
  • 63 Web Application Securi...
  • How to Renew Self-Signed...
  • How to Setup AWS CloudFro...
  • Host Based IDS vs Network...
  • 8 Effective Ways to Impro...
  • Active vs Passive FTP Mod...
  • Top 10 RFID Security Conc...
  • How to Configure AAA (TAC...

Footer

Copyrights

Protected by Copyscape Duplicate Content Detection Software

Securitywing.com reserves the copyrights of all of its published articles.No contents of this site is permitted to be published to anywhere else in the Internet.If any contents are found in any other websites, securitywing reserves the rights to file a DMCA complaint. But you have the right to use the link of any relevant article of this site to point from your website if you consider that it might improve the quality of your article.

Tags

antivirus audit AWS backup browser check cisco cloud computer cyber data database encryption firewall home hsrp ids informaiton internet intrusion it kubernetes linux load balancing malware network protection putty risk router security security tips server ssh SSL switch tools virus vpn vulnerability web webserver website windows wordpress

Copyright © 2010-2023 ·All Rights Reserved · SecurityWing.com