<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Muhammad Ali Ahmed</title>
    <description>The latest articles on Forem by Muhammad Ali Ahmed (@muhammad_aliahmed).</description>
    <link>https://forem.com/muhammad_aliahmed</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1590160%2F148d770b-8b5a-45f8-99b7-16ecad1a875a.jpeg</url>
      <title>Forem: Muhammad Ali Ahmed</title>
      <link>https://forem.com/muhammad_aliahmed</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/muhammad_aliahmed"/>
    <language>en</language>
    <item>
      <title>How to disable root ssh login in Linux</title>
      <dc:creator>Muhammad Ali Ahmed</dc:creator>
      <pubDate>Mon, 26 Aug 2024 11:19:51 +0000</pubDate>
      <link>https://forem.com/muhammad_aliahmed/how-to-disable-root-ssh-login-in-linux-2dj6</link>
      <guid>https://forem.com/muhammad_aliahmed/how-to-disable-root-ssh-login-in-linux-2dj6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Before Getting Started&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;It is important to understand why it is important to disable root ssh login in Linux&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Disabling direct SSH root login is a crucial security measure that helps protect your servers from unauthorized access and potential breaches. Root accounts have unrestricted access to the entire system, so if an attacker gains access to the root account, they can potentially control everything on the server. By disabling root SSH login, you enforce the use of lower-privileged accounts for remote access. Users must log in with their accounts and escalate privileges using sudo if necessary. This minimizes the risk and improves accountability, as each action can be traced back to a specific user rather than the all-powerful root.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You have to edit the sshd_config file&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Navigate to the /etc/ssh directory&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd /etc/ssh&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Open the sshd_config file in a text editor&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nano sshd_config&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vim sshd_config&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Edit the file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Look for the line "PermitRootLogin"&lt;br&gt;
It may be commented out and its value can be yes, no, or &lt;br&gt;
prohibit-password. you have to uncomment it and write&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; PermitRootLogin no
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Restart the ssh service&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo systemctl restart sshd&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The root ssh login will be disabled after the ssh service is &lt;br&gt;
restarted.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>linux</category>
      <category>security</category>
      <category>bash</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>How to separate files owned by a specific user in Linux</title>
      <dc:creator>Muhammad Ali Ahmed</dc:creator>
      <pubDate>Fri, 23 Aug 2024 07:32:13 +0000</pubDate>
      <link>https://forem.com/muhammad_aliahmed/how-to-separate-files-owned-by-specific-users-in-linux-d7d</link>
      <guid>https://forem.com/muhammad_aliahmed/how-to-separate-files-owned-by-specific-users-in-linux-d7d</guid>
      <description>&lt;p&gt;&lt;u&gt;&lt;strong&gt;## In this post we will learn how we can separate files owned by a specific user while maintaining the directory structure in Linux&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Locate files owned by specific users:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;user find command to find files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find /home/usersdata -type f -user ali
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace /home/usersdata with the directory where you want to search for files&lt;/p&gt;

&lt;p&gt;This command will find all files owned by user ali excluding directories.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Install Rsync:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To install it &lt;br&gt;
for centos&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo yum update
sudo yum install rsync
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;for ubuntu&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
sudo apt install rsync
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Copy Files While Preserving Directory Structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can use rsync to copy files while preserving directory structure&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rsync -av --files-from=&amp;lt;(find /home/usersdata -type f -user ali)/ /media
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;rsync -av: Syncs files in "archive" mode, which preserves permissions, timestamps, etc., and provides verbose output.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;--files-from=&amp;lt;(find /home/usersdata -type f -user ali): This specifies the list of files to copy, generated by the find command.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;/: The source directory (root) to consider the paths relative to.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;/media: The destination directory where the files should be copied.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also write the list of files to a temporary file and then use rsync&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;find /home/usersdata -type f -user ali &amp;gt; /tmp/ali_files.txt
rsync -av --files-from=/tmp/ali_files.txt / /media
rm /tmp/ali_files.txt

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>shell</category>
    </item>
  </channel>
</rss>
