<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>root login Archives - Tricky Enough</title>
	<atom:link href="https://www.trickyenough.com/tag/root-login/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.trickyenough.com/tag/root-login/</link>
	<description>Explore and Share the Tech</description>
	<lastBuildDate>Thu, 06 Mar 2025 23:53:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.trickyenough.com/wp-content/uploads/2021/05/favicon-32x32-1.png</url>
	<title>root login Archives - Tricky Enough</title>
	<link>https://www.trickyenough.com/tag/root-login/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">100835972</site>	<item>
		<title>How to Disable Root Login in Ubuntu for Enhanced Server Security?</title>
		<link>https://www.trickyenough.com/how-to-disable-root-login-in-ubuntu-for-enhanced-server-security/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-disable-root-login-in-ubuntu-for-enhanced-server-security</link>
					<comments>https://www.trickyenough.com/how-to-disable-root-login-in-ubuntu-for-enhanced-server-security/#respond</comments>
		
		<dc:creator><![CDATA[Sushant Gupta]]></dc:creator>
		<pubDate>Mon, 24 Feb 2025 11:58:25 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[disable root login ubuntu]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[root login]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://www.trickyenough.com/?p=163479</guid>

					<description><![CDATA[<p>Securing your Linux-based server is a key step toward preventing unauthorized access and security threats. One of the most efficient ways to do this is to disable root login in Ubuntu via SSH. By default, all Linux systems include a root user who has complete control over the system. This means that if an attacker...</p>
<p>The post <a href="https://www.trickyenough.com/how-to-disable-root-login-in-ubuntu-for-enhanced-server-security/">How to Disable Root Login in Ubuntu for Enhanced Server Security?</a> appeared first on <a href="https://www.trickyenough.com">Tricky Enough</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Securing your Linux-based server is a key step toward preventing unauthorized access and security threats. One of the most efficient ways to do this is to disable root login in Ubuntu via SSH.</p>



<p>By default, all <a href="https://www.trickyenough.com/how-to-clear-cache-on-linux/" target="_blank" rel="noreferrer noopener">Linux systems include a root user</a> who has complete control over the system. This means that if an attacker acquires root access, they will be able to completely control, alter, or destroy your server. Allowing root login over SSH raises the risk of brute-force attacks, in which hackers attempt to guess your root password and get access.</p>



<p>To improve security, disable root login and establish a non-root user with administrative access. In this post, we&#8217;ll walk you through the steps to deactivate root login via SSH on Ubuntu, preventing unauthorized users from accessing your server as root.</p>



<h2 class="wp-block-heading"><strong>Step 1: Logging In and Checking Authentication Logs</strong></h2>



<p>Before making any changes to the SSH setup, you must connect to your server as a non-root user with sudo capabilities. You will also check the authentication logs for any unauthorized login attempts.</p>



<h3 class="wp-block-heading"><strong>Accessing Your Server as a Non-Root User</strong></h3>



<p>To log in with a password, run the following line in your terminal:</p>



<p><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">ssh sammy@your_server_ip</mark></em></p>



<p>To perform key-based authentication, use:</p>



<p><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">ssh -i your_private_key sammy@your_server_ip</mark></em></p>



<p><strong>Note:</strong> Replace sammy with the username of your sudo-enabled user and your_server_ip with the IP address of the Ubuntu server.</p>



<p>You should create a sudo-enabled account before removing the root login. Without a sudo user, you may lose administrative control over your server.</p>



<h3 class="wp-block-heading"><strong>Checking Authentication Logs for Unauthorized Access</strong></h3>



<p>Once logged in, go to the authentication logs directory.</p>



<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color"><em>cd /var/log/</em></mark></p>



<p>To view the authentication log, run the following command:</p>



<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color"><em>sudo cat auth.log</em></mark></p>



<p>This log includes all login attempts to your server, both successful and failed. If you notice several failed login attempts, it indicates that someone is attempting to break into your server.</p>



<p>Disabling root login significantly lowers the risk of brute-force attacks and unauthorized access.</p>



<h2 class="wp-block-heading"><strong>Step 2: Disable Root Login Ubuntu Over SSH</strong></h2>



<p>To disable root login, edit the SSH configuration file and restart the SSH service.</p>



<h3 class="wp-block-heading"><strong>Editing the SSH Configuration File</strong></h3>



<p>Open the SSH daemon configuration file with a text editor, such as nano.</p>



<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color"><em>sudo nano /etc/ssh/sshd_config</em></mark></p>



<p>Search for the following line in the file:</p>



<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color"><em>PermitRootLogin yes</em></mark></p>



<p>Change it to:</p>



<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color"><em>PermitRootLogin no</em></mark></p>



<p>This setting informs the SSH daemon to refuse all SSH login attempts from the root user.</p>



<p><strong>Tip:</strong> If the line does not already exist in your configuration file, add it at the end.</p>



<p>After making the changes, save the file by pressing CTRL + X, Y, and Enter.</p>



<h3 class="wp-block-heading"><strong>Restarting the SSH Service</strong></h3>



<p>To apply the modifications, restart the SSH service by running the following command:</p>



<p><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">sudo systemctl restart sshd</mark></em></p>



<p>Restarting the SSH service ensures that any configuration changes take effect immediately.</p>



<h2 class="wp-block-heading"><strong>Step 3: Testing If Root Login Is Disabled</strong></h2>



<p>Now that we&#8217;ve changed the SSH setup, we&#8217;ll see if the root login is disabled.</p>



<h3 class="wp-block-heading"><strong>Attempting to Log In as Root</strong></h3>



<p>Open a new terminal window and attempt to log in as the root user.</p>



<p>In the case of password-based authentication:</p>



<p><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">ssh root@your_server_ip</mark></em></p>



<p>For authentication based on keys:</p>



<p><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">ssh -i your_private_key root@your_server_ip</mark></em></p>



<p>If the changes were successfully implemented, you should get the following error message:</p>



<p>Permission denied; please try again.</p>



<p>This confirms that SSH no longer supports root logins.</p>



<h3 class="wp-block-heading"><strong>Logging In with a Sudo User</strong></h3>



<p>Because root login is disabled, you should now visit the server as a non-root user.</p>



<p>In the case of <a href="https://www.trickyenough.com/advanced-security-systems-must-seen-believed/" target="_blank" rel="noreferrer noopener">password-based authentication</a>:</p>



<p><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">ssh sammy@your_server_ip</mark></em></p>



<p>For authentication based on keys:</p>



<p><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">ssh -i your_private_key sammy@your_server_ip</mark></em></p>



<p>Once logged in, you can use sudo to conduct administrative activities. For example, to upgrade your system, run:</p>



<p><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">sudo apt update &amp;&amp; sudo apt upgrade -y</mark></em></p>



<p>Using a sudo-enabled user allows you to maintain complete control over your system while keeping it secure.</p>



<h2 class="wp-block-heading"><strong>Additional Security Tips</strong></h2>



<p>In addition to blocking root login, you should adopt the following security measures:</p>



<ol class="wp-block-list">
<li><strong>Use SSH Key Authentication:</strong> To improve security, use SSH keys rather than passwords.</li>



<li><strong>Change the SSH Port:</strong> Change the SSH port (22) by default to reduce your risk of brute-force attacks.</li>
</ol>



<p><strong>Enable a Firewall:</strong> Use the Uncomplicated Firewall (UFW) to prevent unwanted access:<br>sudo ufw allow OpenSSH</p>



<p><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">sudo ufw enable</mark></em></p>



<ol start="3" class="wp-block-list">
<li><strong>Use Fail2Ban:</strong> To automatically block IP addresses with a history of unsuccessful login attempts, install Fail2Ban.</li>
</ol>



<p><strong>Regularly Update Your System:</strong> Update your server regularly to fix security flaws.<br><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-green-cyan-color">sudo apt update &amp;&amp; sudo apt upgrade -y</mark></em></p>



<h2 class="wp-block-heading"><strong>Conclusion</strong></h2>



<p>We discussed how to disable root login ubuntu in this article. Ubuntu to make your Linux-based computer more secure. We effectively prevented direct root access by changing the SSH configuration file and restarting the SSH service, which lowered the possibility of unwanted access.</p>



<p>Your server is now more secure with root login disabled, and you may still use a sudo-enabled non-root user to carry out administrative activities.</p>



<p>You can further strengthen your server&#8217;s defenses by following best security practices, which include using SSH keys, changing the default SSH port, and turning on a firewall.</p>
<p>The post <a href="https://www.trickyenough.com/how-to-disable-root-login-in-ubuntu-for-enhanced-server-security/">How to Disable Root Login in Ubuntu for Enhanced Server Security?</a> appeared first on <a href="https://www.trickyenough.com">Tricky Enough</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.trickyenough.com/how-to-disable-root-login-in-ubuntu-for-enhanced-server-security/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">163479</post-id>	</item>
	</channel>
</rss>
