<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kripal Parsekar on Medium]]></title>
        <description><![CDATA[Stories by Kripal Parsekar on Medium]]></description>
        <link>https://medium.com/@kripalparsekar?source=rss-a9a24bfc9608------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mf6CZDi4whqI9QlR</url>
            <title>Stories by Kripal Parsekar on Medium</title>
            <link>https://medium.com/@kripalparsekar?source=rss-a9a24bfc9608------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 18:02:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kripalparsekar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Day 4/100: Script Execution Permissions]]></title>
            <link>https://medium.com/@kripalparsekar/day-4-100-script-execution-permissions-c7d78206e344?source=rss-a9a24bfc9608------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7d78206e344</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[linux-commands]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Kripal Parsekar]]></dc:creator>
            <pubDate>Fri, 21 Nov 2025 08:02:09 GMT</pubDate>
            <atom:updated>2025-11-21T08:02:09.647Z</atom:updated>
            <content:encoded><![CDATA[<p>Challenge Source: Kodekloud — 100 Days of DevOps</p><h3>The Task</h3><blockquote>In a bid to automate backup processes, the <strong>xFusionCorp Industries</strong> sysadmin team has developed a new bash script named <strong>xfusioncorp.sh</strong>. While the script has been distributed to all necessary servers, it lacks executable permissions on <strong>App Server 3</strong> within the Stratos Datacenter.</blockquote><blockquote>Your task is to grant executable permissions to the <strong>/tmp/xfusioncorp.sh</strong> script on <strong>App Server 3</strong>. Additionally, ensure that all users have the capability to execute it.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwQwtbPgySjV00w7iFM79Q.png" /></figure><h3>Introduction</h3><p>Today’s task was straightforward: a backup script was already present on the server, but it was not executable by any user. The goal was simply to adjust its permissions so it could be run by everyone.</p><p>Despite the simplicity of the fix, it exposed an interesting nuance in how Linux handles interpreted scripts, particularly the way read and execute permissions work together. It was a detail I had overlooked before starting the task, and it ended up being the most valuable part of today’s learning.</p><h3>Objective</h3><p>The task can be broken down into two steps:</p><ol><li>Give the script executable permissions so that all users are allowed to run it.</li><li>Verify that the script runs successfully after updating the permissions to ensure the changes were applied correctly.</li></ol><p>If you are here just for the task solution, skip to <a href="#b584"><strong>this</strong></a><strong> </strong>section.</p><h3><strong>Understanding the Concept</strong></h3><h4>How Linux File Permissions Work</h4><p>Linux assigns three permission types: read (r), write (w) and execute (x), to three different categories: the <strong>owner</strong>, the <strong>group</strong> and <strong>others</strong>. These permissions determine who can view, modify or run a file.</p><p>For example, consider this file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*dLeJIQ7OGRcJ1Kzq0DYJfA.png" /></figure><p>Here is what each part means:</p><p><strong>-</strong> specifies the file is a regular file (not a directory).<br><strong>rwx </strong>specifies the file owner’s permissions, <strong>tonto </strong>can read, write and execute the file.<br><strong>r-x </strong>specifies the permissions of the file for the group members;<strong> </strong>members of the <strong>cloud </strong>group can read and execute it, but cannot edit it.<br><strong>--- </strong>specifies permission for all other users;<strong> </strong>all other users on the system have <strong>no access at all</strong>. They cannot read, write or execute the file.<br><strong>tonto </strong>is the user who owns the file.<br><strong>cloud</strong> is the group associated with the file.</p><p>This layout defines exactly how the system treats the file for each user category. In this case, only <strong>tonto</strong> and users in the <strong>cloud</strong> group are allowed to run the script, and only <strong>tonto</strong> is allowed to modify it.</p><h4><strong>How Linux Executes a Script</strong></h4><p>When a script is run directly using ./script.sh, Linux follows a specific sequence to decide how it should be executed.</p><p>First, the kernel checks whether the script has the execute (x) bit set. Without this permission, the file cannot be treated as an executable at all.</p><p>Once that check passes, the kernel reads the shebang line at the top of the script (for example, #!/bin/bash) to determine which interpreter should run it. The interpreter is then launched as a separate process, and it attempts to open and read the script.</p><p>This final step is important: interpreted scripts must also have read (r) permission, or the interpreter will fail when trying to process the file. This is why both read and execute permissions are necessary for scripts to run correctly.</p><h4>How chmod Adjusts Permissions</h4><p>The chmod command is used to modify these permission bits. It can work in two ways: <strong>symbolic mode</strong> and <strong>numeric mode</strong>, each useful in different situations.</p><p><strong>Symbolic mode</strong></p><pre>chmod a+x file.sh    # give execute permission to everyone<br>chmod g-w file.sh    # remove write permission from the group</pre><p>Symbolic mode describes changes in terms of adding or removing specific permissions. It is useful when you want to make small, targeted adjustments without affecting other bits.</p><p><strong>Numeric mode</strong></p><p>Permissions can also be set using octal numbers, where read = 4, write = 2 and execute = 1. These values combine to represent the full permission set.</p><pre>chmod 755 file.sh    # rwxr-xr-x<br>chmod 644 config.txt # rw-r--r--</pre><p>Numeric mode is ideal when you want to apply complete permission sets in a single command, especially for scripts or configuration files that must match a predictable pattern.</p><h3>Applying the Permissions Fix</h3><p>Since the script we need to fix is on <strong>App Server 3</strong>, the first step is to SSH into it.</p><pre>#SSH into App Server 3<br>ssh banner@stapp03.stratos.xfusioncorp.com</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*PxCOGb7eYG_sz7qLh6nSWw.png" /></figure><p>Once we are in the server, we move to the /tmp directory where the script is located and inspect the directory for our script.</p><pre>#Move to the directory where the script is stored and list the files in the directory<br>cd /tmp<br>ls -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*cbLOBlcFC1v9B26lG8QSpQ.png" /></figure><p>I checked the permissions of the script and noticed that xfusioncorp.sh had no permissions at all, not even read access.</p><p>Before applying the final fix, I wanted to test what would happen if I added only the execute bit. So I gave the file execute permissions only.</p><pre>#Add execute permission on the file for user, group and others<br>sudo chmod a+x xfusioncorp.sh<br><br>#Run the bash script<br>./xfusioncorp.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*ZQaklDW6bkOXnf3bcXwFFA.png" /></figure><p>As expected, running the script resulted in a <strong>Permission denied</strong> error.</p><p>This happened because running a script does more than just “execute a file”. The moment the kernel sees the shebang at the top of the script, it calls the interpreter (in this case /bin/bash). The bash interpreter then tries to read the contents of the script. Since the file had <strong>no read permissions</strong>, the interpreter simply could not read or execute anything inside it.</p><p>To fix this properly, I added the <strong>read</strong> permission to the file.</p><pre>sudo chmod a+r xfusioncorp.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*gwZ_lJNlfUNp-sNmF9QDyg.png" /></figure><p>The script was then able to run and display the message ‘Welcome to Kodekloud’.</p><p>Alternatively, instead of adding read and execute permissions separately, I could have assigned both together using symbolic notation like chmod a+rx xfusioncorp.sh or by applying the numeric equivalent chmod 555 xfusioncorp.sh.</p><p>With that, the permissions issue is resolved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*o0KqtOM6-7T0yujAb7BMOA.gif" /></figure><h3>Concluding with Reflection</h3><p>Today’s task was quick, but it highlighted something I had overlooked about how interpreted scripts work. I initially assumed that giving a script execute permission would be enough, but running into a Permission denied error made me realise that the interpreter also needs read access to the file. It is a small detail, but understanding it makes troubleshooting these issues much easier.</p><p>This was another reminder that even simple tasks help reinforce the fundamentals. Linux permissions show up everywhere, and knowing how they behave in different situations saves a lot of confusion later. Each of these small lessons adds up over time. #100DaysOfDevOps</p><h3>Key Takeaways</h3><ul><li>Interpreted scripts require both <strong>read</strong> and <strong>execute</strong> permissions to run properly.</li><li>The execute bit alone is not enough, because the interpreter still needs access to the script’s contents.</li></ul><h3><strong>References</strong></h3><ul><li><a href="https://kodekloud.com/100-days-of-devops">https://kodekloud.com/100-days-of-devops</a></li><li><a href="https://stackoverflow.com/questions/15757357/i-want-a-shell-script-to-be-executable-but-not-readable">https://stackoverflow.com/questions/15757357/i-want-a-shell-script-to-be-executable-but-not-readable</a></li><li><a href="https://unix.stackexchange.com/questions/387265/why-i-cant-execute-script-with-only-execution-permission">https://unix.stackexchange.com/questions/387265/why-i-cant-execute-script-with-only-execution-permission</a></li></ul><h3>Follow My Journey on 100 Days of DevOps</h3><p>This article is part of a series documenting my progress through KodeKloud’s 100 Days of DevOps challenge.</p><p><a href="https://kodekloud.com/100-days-of-devops">100 Days of DevOps | KodeKloud</a></p><p>Previous Post: Day 3/100:<a href="https://medium.com/@kripalparsekar/day-3-100-secure-root-ssh-access-6aaafd08c8fa"> Secure Root SSH Access</a><br>Next Post: Day 5/100: SELinux Installation and Configuration</p><p>Follow my #100DaysOfDevOps journey here on <a href="https://medium.com/@kripalparsekar/list/100-days-of-devops-1d3cf1958177">Medium </a>or connect with me on <a href="https://www.linkedin.com/in/kripalparsekar/">LinkedIn</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*f8WsoSzAyvzCuuMp3fd_Fg.gif" /></figure><p>#100DaysOfDevOps, #Linux, #SysAdmin, #DevOps, #KodeKloud.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7d78206e344" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 3/100: Secure Root SSH Access]]></title>
            <link>https://medium.com/@kripalparsekar/day-3-100-secure-root-ssh-access-6aaafd08c8fa?source=rss-a9a24bfc9608------2</link>
            <guid isPermaLink="false">https://medium.com/p/6aaafd08c8fa</guid>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[devops-fundamentals]]></category>
            <category><![CDATA[linux-server-hardening]]></category>
            <category><![CDATA[sshd]]></category>
            <category><![CDATA[cis-benchmarks]]></category>
            <dc:creator><![CDATA[Kripal Parsekar]]></dc:creator>
            <pubDate>Sat, 15 Nov 2025 08:02:06 GMT</pubDate>
            <atom:updated>2025-11-26T19:38:34.556Z</atom:updated>
            <content:encoded><![CDATA[<h4>Challenge Source: KodeKloud — 100 Days of DevOps</h4><h3>The Task</h3><blockquote>Following security audits, the <strong>xFusionCorp Industries</strong> security team has rolled out new protocols, including the restriction of direct root SSH login.</blockquote><blockquote>Your task is to disable direct SSH root login on all app servers within the <strong>Stratos Datacenter</strong>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*2-Cnod6FK2Zfxr8Q9NuFdw.gif" /></figure><h3>Introduction</h3><p>If you have worked with a Linux server, you have almost certainly come across SSH. SSH is the standard way we access servers over a network, whether it is a personal virtual machine, a production server or a jump host in a larger environment.</p><p>Before SSH became the norm, administrators relied on Telnet, a protocol that sent everything, including passwords, in plain text. Not great. I have never used Telnet for remote access myself, but it is still a useful little utility even today when you need to check whether a port on a server is reachable.</p><p>SSH solved this by providing encrypted communication, which made remote access far more secure and reliable.</p><p>In today’s task, we take that security a step further by hardening our server and disabling direct root SSH access.</p><h3>What We Need to Achieve</h3><p>We can break down the task as follows:</p><ol><li><strong>Understand the risk of direct root SSH access:</strong> as it gives full control to anyone who logs in and reduces accountability.</li><li><strong>Update the SSH settings to block direct root login:</strong> this improves the overall security posture of the server.</li></ol><p>If you are here just for the task solution, feel free to skip ahead to <a href="#3dc4"><strong>this</strong> </a>section.</p><h3>Key Concepts to Understand Before We Start</h3><h4>Why We Disable Root Access</h4><p>Direct root SSH access gives anyone who logs in complete and unrestricted control of the server. This makes it a high-risk entry point, especially in environments where several people may need administrative access. Security standards also widely recommend disabling direct root logins because automated attacks often target the root user first, and a single successful attempt can compromise the entire system.</p><p>There is also an important accountability aspect. Industry hardening guidelines highlight that administrators should authenticate with their own user accounts and then escalate privileges with sudo. This creates a clear audit trail and prevents situations where multiple people share the same root login, which would otherwise make tracking actions difficult during a security incident.</p><h4>Important Files for This Configuration Change</h4><p>The main file involved in this task is /etc/ssh/sshd_config. This is the file the SSH server reads to decide who can log in and how authentication should work. The PermitRootLogin setting is defined here, and any mistakes in this file can prevent the SSH service from starting properly, so it is important to edit it carefully.</p><p>There is also a file called /etc/ssh/ssh_config, but this applies only to the SSH client. It does not influence server-side login permissions and should not be used when restricting root access.</p><h4>How SSH Applies These Changes</h4><p>SSH does not automatically load new settings when the configuration file is changed. The SSH daemon needs to be reloaded so it can apply the updated rules. Reloading is the safer option, as it keeps your current connection active while applying the new configuration in the background.</p><p>After the reload, you can confirm the change by checking the effective configuration:</p><pre>#Command to run extended test on SSH daemon configuration<br>sshd -T</pre><p>Now that we have understood how things work under the hood, let’s work on the task.</p><h3>Now for the Practical Part</h3><p>Since we are asked to perform this task on all three application servers(<strong>stapp01, </strong><strong>stapp02, </strong><strong>stapp03</strong>), the following steps will have to be repeated for the other application servers. The steps shown below were implemented on <strong>stapp01</strong>.</p><p>Firstly, SSH into the server using the username and password provided in the information sheet for the first server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*lj2pV7kAvCZUXU_r0xofJg.png" /><figcaption>SSHing into strapp01</figcaption></figure><p>Let’s now inspect the SSH daemon configuration file. The file is located at the absolute path /etc/ssh/sshd_config. Open it using your preferred text editor. In my case, I will be using vi, and the command is sudo vi /etc/ssh/sshd_config. The file requires root privileges to open. Once opened, scroll down until you see the line containing PermitRootLogin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*0_AfZ0SyL6Cgy0PKNPa9Lw.png" /><figcaption>Content of /etc/ssh/sshd_config before disabling root login access.</figcaption></figure><p>You’ll typically see something like PermitRootLogin yes. Uncomment the line if needed (remove the #) and change the value to no.</p><p>Your file should now look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*lxrhSO6hhBId5UqGkui5vw.png" /><figcaption>Content of /etc/ssh/sshd_config after disabling root login access.</figcaption></figure><p>You can now save and exit the text editor. Before applying the changes, we should check whether the configuration file contains any syntax errors. This can be done by running sudo sshd -t. If the command returns no output, it means the configuration file does not have any syntax errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*iVWzYiqPr7T5d288x-bSSQ.png" /><figcaption>Checking configuration file syntax.</figcaption></figure><p>Now apply the changes by reloading the SSH daemon using sudo systemctl reload sshd, followed by sudo systemctl status sshd to confirm that the SSH service is running correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*oyHui2V-9vKkoIrOA0zfkw.png" /><figcaption>Checking status of SSH daemone after applying configuration.</figcaption></figure><p>Next, we can validate the changes either by trying to SSH as the root user, or by checking whether the configuration has been applied correctly. Since attempting to log in as root still prompts for a password we do not have, we will validate the change by checking the active SSH daemon configuration instead.</p><p>The applied configuration can be checked by running the extended test mode, sudo sshd -T, which displays the effective configuration. The grep command after the pipe filters the configuration file for only permitrootlogin configuration. You should see the output: permitrootlogin no.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*xR_VISpuhTpvFsQKJu5D_g.png" /><figcaption>Checking if the new configurations are applied.</figcaption></figure><p>Repeat these same steps on stapp02 and stapp03 using their respective credentials from the information sheet. Once complete, direct root SSH login will be disabled across all app servers in the Stratos Datacenter.<br> Yayyy!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*m5vnxkpm0YFb6wrObPt-Dw.gif" /></figure><h3>Concluding with Reflection</h3><p>Today’s task was a simple one on paper, but it highlighted an important point about server security. Disabling direct root SSH access is just a single line in a configuration file, yet it significantly improves accountability and reduces risk. It reminded me that not every security improvement needs a complex setup; sometimes it’s about knowing which defaults to change and using safer practices like logging in with a normal user and elevating with sudo.</p><p>It also encouraged me to look beyond the task itself. Security guidelines and benchmarks, including the freely available CIS documents and distribution-specific hardening guides, explain why changes like this matter in real environments. They are great resources for anyone trying to build stronger server-hardening habits.</p><p>Small improvements like this build a strong foundation, one configuration change at a time. #100DaysOfDevOps</p><h3>Key Takeaways</h3><ul><li>Disabling direct root SSH access removes a major security risk and improves accountability.</li><li>The PermitRootLogin setting in sshd_config is a simple but effective way to harden a server.</li><li>Validating changes with sshd -t and sshd -T helps avoid misconfigurations and accidental lockouts.</li></ul><h3>References</h3><ul><li><a href="https://kodekloud.com/100-days-of-devops">https://kodekloud.com/100-days-of-devops</a></li><li><a href="https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/security_guide/sec-controlling_root_access">https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/7/html/security_guide/sec-controlling_root_access</a></li><li><a href="https://www.cisecurity.org/">https://www.cisecurity.org/</a></li></ul><h3>Follow My Journey on 100 Days of DevOps</h3><p>This article is part of a series documenting my progress through KodeKloud’s 100 Days of DevOps challenge.</p><p><a href="https://kodekloud.com/100-days-of-devops">100 Days of DevOps | KodeKloud</a></p><p>Previous Post: Day 2/100: <a href="https://medium.com/@kripalparsekar/day-2-100-temporary-user-setup-with-expiry-b79b62d79c65">Temporary User Setup with Expiry</a><br>Next Post: Day 4/100: <a href="https://medium.com/@kripalparsekar/day-4-100-script-execution-permissions-c7d78206e344">Script Execution Permissions</a></p><p>Follow my #100DaysOfDevOps journey here on <a href="https://medium.com/@kripalparsekar/list/100-days-of-devops-1d3cf1958177">Medium </a>or connect with me on <a href="https://www.linkedin.com/in/kripalparsekar/">LinkedIn</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*WKJWlylRB1BuKZMD5IZcxQ.gif" /></figure><p>#100DaysOfDevOps, #Linux, #SysAdmin, #DevOps, #KodeKloud.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6aaafd08c8fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 2/100: Temporary User Setup with Expiry]]></title>
            <link>https://medium.com/@kripalparsekar/day-2-100-temporary-user-setup-with-expiry-b79b62d79c65?source=rss-a9a24bfc9608------2</link>
            <guid isPermaLink="false">https://medium.com/p/b79b62d79c65</guid>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Kripal Parsekar]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 11:34:11 GMT</pubDate>
            <atom:updated>2025-11-26T19:40:16.000Z</atom:updated>
            <content:encoded><![CDATA[<h4>Challenge Source: KodeKloud — 100 Days of DevOps</h4><h3><strong>The Task</strong></h3><blockquote>As part of the temporary assignment to the Nautilus project, a developer named <strong>jim</strong> requires access for a limited duration. To ensure smooth access management, a temporary user account with an expiry date is needed. Here&#39;s what you need to do:</blockquote><blockquote>Create a user named <strong>jim </strong>on <strong>App Server 3</strong> in Stratos Datacenter. Set the expiry date to <strong>2024-02-17</strong>, ensuring the user is created in lowercase as per standard protocol.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*Lzg2tIa-kxRVSA7w7oWX6A.gif" /></figure><h3><strong>Introduction</strong></h3><p>How many times have you created a user account for a recruit, a service, a POC someone asked you to do, or just a quick test user, and then left them stranded longer than they should have been?</p><p>When I first got handed a Linux admin role a couple of years ago, I barely knew what I was doing. I’d open the /etc/passwd file, stare at a bunch of usernames, and wonder, “Who even created half of these accounts, and why?” And I’m pretty sure I was responsible for most of them.</p><p>Leaving unused accounts lying around isn’t just untidy, it’s a security risk. Forgotten credentials can become backdoors, and over time, these orphaned accounts pile up, creating blind spots in access control that no audit tool can magically clean up.</p><p>This task covers one of those use cases, automating account expiry so access ends when it should. The <a href="https://medium.com/@kripalparsekar/day-1-100-linux-user-setup-with-non-interactive-shell-dff67c191754">Day 1</a> challenge was about controlling <em>how</em> a user accesses the system; today’s is about controlling <em>when</em> and <em>for how long</em> they can.</p><h3><strong>Here is what we need to do</strong></h3><p>We can break down the task as follows:</p><ol><li><strong>Create a normal user:</strong> since it’s for a developer working on Nautilus.</li><li><strong>Set an expiration date for the account:</strong> the developer needs temporary access to the server.</li></ol><p>If you are here just for the task solution, head down to <a href="#2504">this </a>section.</p><h3><strong>A few concepts to understand before we proceed.</strong></h3><h4><strong>User Lifecycle and PAM</strong></h4><p>Every user account in Linux follows a simple lifecycle: creation, active use, ageing, and eventual deactivation. System tools manage this lifecycle, and the PAM (Pluggable Authentication Modules) framework enforces it.</p><p>Linux tracks this lifecycle securely in the /etc/shadow file, where each user entry consists of nine colon-separated fields:</p><ul><li><strong>Field 1</strong>: The name of the user</li><li><strong>Field 2</strong>: Encrypted password (or lock indicator with ! prefix)</li><li><strong>Field 3</strong>: Last password change (days since January 1, 1970)</li><li><strong>Fields 4–7</strong>: Password ageing controls</li><li><strong>Field 8</strong>: Account expiration date (days since epoch; -1 = never)</li><li><strong>Field 9</strong>: Reserved for future use</li></ul><p>This centralised, root-only readable structure enables consistent tracking and enforcement of security policies system-wide.</p><p>During login, PAM compares the current time with the time fields in /etc/shadow. For example, if a user <strong>anita</strong> has an account expiry set to <strong>11 November 2025</strong>:</p><pre>if today &gt; 11/11/2025 → deny access: &quot;Account expired&quot;<br>else → allow access (subject to other checks)</pre><p>These checks run in real time and apply uniformly across all PAM-aware services (SSH, console, su, etc.), regardless of access method.</p><p>Now that we have a brief understanding of how Linux keeps track of user accounts under the hood, let’s look at the two main ways to disable them: locking and expiration.</p><h4><strong>Account Locking vs Account Expiration</strong></h4><p>Both locking and expiration disable user access, but they work at different levels, block different things, and serve different situations.</p><p><strong>Account Locking</strong> prevents password-based authentication by modifying <strong>Field 2</strong> /etc/shadow to prepend a ! or !! to the encrypted password hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4DO-trikNwxkn6G2-PtvgQ.png" /><figcaption>Password hash before and after account locking.</figcaption></figure><p>This blocks logins via login, su, sudo, or SSH using a password.</p><pre># Lock the user account<br>sudo passwd -l dwight<br># or<br>sudo usermod -L dwight<br><br># Unlock the user account<br>sudo passwd -u dwight<br># or<br>sudo usermod -U dwight</pre><p>However, non-password methods remain functional: SSH public key authentication, Kerberos tickets, or any PAM module that bypasses password verification.</p><p>This occurs because locking only modifies the <strong>encrypted password hash,</strong>i.e.<strong> Field 2</strong> in /etc/shadow. Authentication methods like SSH keys and Kerberos bypass the password hash check entirely.</p><p>Use account locking in situations requiring immediate but reversible access restriction, such as:</p><ul><li>Suspected credential compromise</li><li>Policy or security violations</li><li>Temporary suspension (e.g., employee on leave, expected to return)</li></ul><p>While <strong>Account Expiration</strong>, on the other hand, completely disables login, no matter what method is used. It renders the user account inaccessible after a specified date by setting <strong>Field 8</strong> in /etc/shadow to the number of days since January 1, 1970(Unix Epoch!!!).</p><pre># Set an account to expire on a specific date<br>sudo chage -E 2024-02-17 jim<br># or<br>sudo usermod --expiredate 2024-02-17 jim<br><br># Remove an expiry date (make the account permanent)<br>sudo chage -E -1 jim<br><br># Force immediate account expiration<br>sudo chage -E 0 jim<br><br># Verify the expiry date<br>sudo chage -l jim</pre><p>Note: chage is purpose-built for expiry management, while usermod is the general-purpose account modification tool. Both work equally well for setting expiration dates.</p><p>From that date onward, <strong>all authentication methods fail, </strong>including passwords, SSH keys, Kerberos, cron jobs, sudo, or any PAM-aware service, with the error, ‘<em>Account has expired’.</em></p><p>Processes that were already running continue, but the user cannot start new sessions or spawn new processes.</p><p>Use account expiration for “<strong>planned offboarding”</strong>, such as:</p><ul><li>Contractors with fixed end dates</li><li>Student or guest accounts after a semester/project</li><li>Temporary access for audits or trials</li></ul><h3><strong>Let’s get to it</strong></h3><p>Now that we are backed up with a few bits a level below the task requirement, let&#39;s start by first SSHing onto <strong><em>App Server 3</em></strong> in Stratos Datacenter.</p><pre>ssh banner@stapp03.stratos.xfusioncorp.com</pre><p>Although this is not a necessary step, let&#39;s check if the user is already created by inspecting the /etc/passwd file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OpWX50h2E0o3uVdOhDrvDQ.png" /><figcaption>Inspecting /etc/passwd file for user.</figcaption></figure><p>Since the user isn&#39;t present on the system, create it with the following command. We can specify the account expiry within the user create command with the -E or — expiredate option.</p><pre>#Creating a user with expiry date.<br>sudo adduser --expiredate 2024-02-17 jim</pre><p>If you already created the user, use this command to expire or force-expire the account.</p><pre>#Adding account expiry to already created user.<br>sudo usermod --expiredate 2024-02-17 jim</pre><p>We can validate the expiry date of the user account by running sudo chage -l jim command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*qGYyg_yA3lQsgnmMvUZARA.png" /><figcaption>We can see the expiry date set to 17 Feb 2024</figcaption></figure><p>Another way we can validate our task is by actually logging in with the user created. At the time of writing this article, the date given by the task was in the past; hence, logging in should give us an error. Let&#39;s try it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4xqv3QWK2dgDQ9kyUe1jeg.png" /><figcaption>Unable to log into account due to expiry.</figcaption></figure><p>Since I completed this task after February 17, 2024, attempting to log in as <strong>jim </strong>demonstrates the expiry mechanism working correctly, PAM blocks the login with an ‘Account has expired’ error. Yayyyyy!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Fa3T2SgRjwbKOfDl7qYqLw.gif" /></figure><h3>Concluding with Reflection</h3><p>Day 2 might have been a quick one, but it added an important layer to what I learned on Day 1. Setting up a temporary user wasn’t just another account-creation task, it introduced the idea of managing when access should end, not just how it begins.</p><p>It’s easy to overlook expiry dates when you’re focused on getting systems running, but this exercise reminded me that cleanup and lifecycle control are just as critical in DevOps as provisioning. A single flag like --expiredate can quietly enforce security and save future headaches.</p><p>Here’s to small, practical lessons that build real habits, one day, one command at a time. #100DaysOfDevOps</p><h3>Key Takeaways</h3><ul><li>Temporary user accounts help enforce proper access lifecycles and prevent forgotten credentials from lingering in systems.</li><li>The --expiredate flag while creating a user or chage -E command can automate user offboarding without manual cleanup.</li><li><strong>PAM (Pluggable Authentication Modules)</strong> silently enforces these rules during login by checking details in /etc/shadow.</li><li>Account locking is for immediate restriction, while expiration is for planned, time-bound deactivation.</li></ul><h3>References</h3><ul><li><a href="https://kodekloud.com/100-days-of-devops">https://kodekloud.com/100-days-of-devops</a></li><li><a href="https://manpages.ubuntu.com/manpages/jammy/en/man5/shadow.5.html">https://manpages.ubuntu.com/manpages/jammy/en/man5/shadow.5.html</a></li><li><a href="https://www.redhat.com/en/blog/pluggable-authentication-modules-pam">https://www.redhat.com/en/blog/pluggable-authentication-modules-pam</a></li><li><a href="https://linuxopsys.com/chage-command-in-linux">https://linuxopsys.com/chage-command-in-linux</a></li><li><a href="https://unix.stackexchange.com/questions/570224/whats-the-difference-between-locking-and-expiring-a-user-account">https://unix.stackexchange.com/questions/570224/whats-the-difference-between-locking-and-expiring-a-user-account</a></li><li><a href="https://askubuntu.com/questions/1083252/why-should-we-expire-a-locked-account-to-totally-prevent-access">https://askubuntu.com/questions/1083252/why-should-we-expire-a-locked-account-to-totally-prevent-access</a></li><li><a href="https://unix.stackexchange.com/questions/749447/whats-the-difference-between-account-expiryinactive-and-account-becoming-lock">https://unix.stackexchange.com/questions/749447/whats-the-difference-between-account-expiryinactive-and-account-becoming-lock</a></li></ul><h3><strong>Follow My Journey on 100 Days of DevOps</strong></h3><p>This article is part of a series documenting my progress through KodeKloud’s 100 Days of DevOps challenge.</p><p><a href="https://kodekloud.com/100-days-of-devops">100 Days of DevOps | KodeKloud</a></p><p>Previous Post: Day 1/100: <a href="https://medium.com/@kripalparsekar/day-1-100-linux-user-setup-with-non-interactive-shell-dff67c191754">Linux User Setup with Non-Interactive Shell</a><br>Next Post: Day 3/100: <a href="https://medium.com/@kripalparsekar/day-3-100-secure-root-ssh-access-6aaafd08c8fa">Secure Root SSH Access</a></p><p>Follow my #100DaysOfDevOps journey here on <a href="https://medium.com/@kripalparsekar/list/100-days-of-devops-1d3cf1958177">Medium </a>or connect with me on <a href="https://www.linkedin.com/in/kripalparsekar/">LinkedIn</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*89S4T1tqZIWZgUnhvxcLyA.gif" /></figure><p>#100DaysOfDevOps, #Linux, #SysAdmin, #DevOps, #KodeKloud.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b79b62d79c65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 1/100: Linux User Setup with Non-Interactive Shell]]></title>
            <link>https://medium.com/@kripalparsekar/day-1-100-linux-user-setup-with-non-interactive-shell-dff67c191754?source=rss-a9a24bfc9608------2</link>
            <guid isPermaLink="false">https://medium.com/p/dff67c191754</guid>
            <dc:creator><![CDATA[Kripal Parsekar]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 08:02:13 GMT</pubDate>
            <atom:updated>2026-05-10T06:22:41.370Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Linux User Setup with Non-Interactive Shell</strong></h3><p>Challenge Source: KodeKloud — 100 Days of DevOps</p><h3><strong>The Task</strong></h3><blockquote>To accommodate the backup agent tool’s specifications, the system admin team at xFusionCorp Industries requires the creation of a user with a non-interactive shell. Here’s your task:</blockquote><blockquote>Create a user named john with a non-interactive shell on App Server 2.</blockquote><h3><strong>Introduction</strong></h3><p>At first, I thought of using the useradd command, but then I got confused. Was it adduser instead? I often mix these two Linux commands up, so I decided to double-check when I got to that step.</p><p>Reading the task carefully, it turned out to be a simple user creation step, except that the user shouldn’t have an interactive shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*N-UoGKPhsl0TJOnN.gif" /></figure><h3><strong>So, what are we supposed to do?</strong></h3><p>The task has two main requirements:</p><ol><li><strong>Create a system user:</strong> Since the user account is intended for a tool, we must create a <em>system</em> account, not a regular user.</li><li><strong>Assign a non-interactive shell:</strong> Because the user doesn’t need to perform normal interactive tasks, it should not be able to log in.</li></ol><p>Before jumping into the commands, let’s take a moment to understand some concepts behind this task.</p><p>If you’re already familiar with these concepts and just want to see the implementation, feel free to skip ahead to <a href="#f39c"><strong>this </strong></a>section.</p><h3><strong>Key concepts to understand before we proceed.</strong></h3><h4><strong>Why do we even need users on a Linux system?</strong></h4><p>A Linux system can host multiple users and processes simultaneously. Each user account acts as an <strong>isolation layer,</strong> defining who can log in, what files they can access, and what actions they’re allowed to perform. This control mechanism helps enforce key security principles:</p><ul><li><strong>Authentication:</strong> verifying who is trying to access the system.</li><li><strong>Authorisation:</strong> determining what the user is allowed to do.</li><li><strong>Principle of Least Privilege (PoLP):</strong> ensuring that every user or process has only the minimal permissions required to perform its function and nothing more.</li></ul><p>Together, these principles allow administrators to delegate specific access to users or applications while protecting critical system components.</p><h4><strong>And is it </strong><strong>useradd or </strong><strong>adduser?</strong></h4><p>This is a classic point of confusion (at least for me); both commands are used to create users, but they behave slightly differently.</p><ul><li><strong>useradd</strong> is a <strong>low-level utility</strong> written in C. It’s fast, minimal, and requires explicit options for home directories, shells, etc.</li><li><strong>adduser</strong> is a <strong>Perl wrapper</strong> around <strong>useradd</strong>, designed for ease of use. It’s more interactive and automatically sets default values for the home directory, permissions, and shell.</li></ul><p>In short:</p><ul><li>Use <strong>adduser</strong> when you want a <strong>more guided, interactive setup</strong>.</li><li>Use <strong>useradd</strong> for <strong>scripting or automation, where you need full control</strong>.</li></ul><p>Regardless of which you use, always check the <strong>manual pages</strong> to confirm available options and defaults, as they can vary slightly between distributions.</p><h4><strong>What is a Non-Interactive Shell?</strong></h4><p>A <strong>non-interactive shell</strong> (like <strong>/usr/sbin/nologin</strong> or <strong>/bin/false</strong>) prevents the user from accessing the system directly. Instead of opening a command prompt, it immediately exits or displays a message. This is ideal for system users who only need background-level access for services, hence reducing attack surfaces and improving system security.</p><p>While both <strong>/usr/sbin/nologin</strong> and <strong>/bin/false</strong> can prevent interactive logins, <strong>/usr/sbin/nologin</strong> is preferred because it’s specifically designed for this purpose. It provides a clear message, like ‘<em>This account is currently not available</em>’, making it easier to troubleshoot. In contrast, the <strong>/bin/false</strong> method is a legacy approach that simply exits without feedback, which can be less intuitive.</p><h3><strong>Getting Our Hands Dirty</strong></h3><p>Now that we have understood the concept needed to complete the task, let’s get started with the lab.</p><p>First, we need to SSH into App Server 2. We can find the user details and the server hostname from the Users and Servers detail document linked next to the Stop Lab button.</p><pre>ssh steve@stapp02.stratos.xfusioncorp.com</pre><p>Once I SSH’d my way into the server. It would be better to check if the user named <strong>john</strong> is already created. I inspected the /etc/passwd file to confirm the userjohn didn’t exist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Cb1HihKGm34oVEFMK_ps_Q.png" /><figcaption>Verifying /etc/passwd Before Creation</figcaption></figure><p>Now we can run the command to create the system user.</p><pre>sudo adduser --system --shell /usr/sbin/nologin john</pre><p>Though the command looks quite clear, I’ll briefly explain it.</p><p><strong>sudo</strong> runs the command with root privileges.<br><strong>adduser</strong> is the command to add a new user.<br><strong>— system</strong> specifies that the user is a system user.<br><strong>— shell /usr/sbin/nologin</strong> specifies the shell for the user.<br><strong>john</strong> finally, the name of the new user.</p><p>The command ran without error. Seems like nothing went south. Let’s check if the user is created. First, we can check the <strong>/etc/passwd</strong> file again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*o_tukxT0K6aHrFeaTQ6j5A.png" /><figcaption>/etc/passwd after user creation</figcaption></figure><p>The <strong>/etc/passwd</strong> file showed has the entry <strong>john:x:998:998::/home/john:/usr/sbin/nologin</strong>, confirming the system UID and non-interactive shell.</p><p>The UID of 998 confirms <strong>john </strong>is a system user, as system users typically have UIDs below 1000, unlike regular users who start above 1000, to differentiate their roles for services like the backup agent. Also, note that the shell for the user is <strong>/usr/sbin/nologin</strong>.</p><p>Why do we have a home directory set as <strong>/home/john,</strong> though?</p><p>Let’s check if a home directory for the new user was created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*cZ0GbBTiiuJoKHBjumhZmQ.png" /><figcaption>Output of ls /home showing no /home/john directory.</figcaption></figure><p>The <strong>--system</strong> flag sets the default home directory within the <strong>/etc/passwd</strong> file for compatibility; however, the home directory is never created physically. I ran <strong>ls /home</strong> to confirm that no <strong>/home/john</strong> directory existed.</p><p>Let’s also check if the user can log in interactively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*_RKrx3WHUNItDiX76KwWiA.png" /><figcaption>Logging in with a non-interactive user</figcaption></figure><p>Logging in with a system user with a shell set to <strong>/usr/sbin/nologin,</strong> I was greeted with a polite <strong><em>“This account is currently not available”</em></strong> message in the shell.</p><p>These verifications, i.e., checking the entry of user <strong>*john*</strong> in the <strong>/etc/passwd</strong> file, the home directory not being created for system user, and the non-interactive shell, are quite an indicator that we have completed our task.</p><p><strong>Yayyyy!!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*64-a7SALSf8l671I.gif" /></figure><h3><strong>Concluding with Reflection</strong></h3><p>Day 1 of KodeKloud’s 100 Days of DevOps kicked off with a classic sysadmin task that’s foundational for DevOps. Beyond just running the command, I explored nuances like how user creation differs across distributions (e.g., Ubuntu vs. CentOS) and grasped key sysadmin concepts like PoLP and system user management.</p><p>Writing this article was fun, but it took longer than the task itself! I’m grateful to KodeKloud for providing this hands-on challenge, which inspires me to learn and share knowledge daily.</p><p>Share your user management tips and insights in the comments, and join me for subsequent challenges! #100DaysOfDevOps</p><h3><strong>Key Takeaways</strong></h3><ul><li>User management is a critical sysadmin skill, foundational for DevOps tasks like automating secure service accounts.</li><li>Following the Principle of Least Privilege (PoLP) is best practice in system administration, ensuring users and services have only the permissions they need.</li><li>System users, with UIDs below 1000, are designed for services and tools, unlike regular users for interactive logins.</li><li>It’s okay to forget commands, manual pages, and online documentation are there to help.</li></ul><h3><strong>References</strong></h3><ul><li><a href="https://kodekloud.com/100-days-of-devops">https://kodekloud.com/100-days-of-devops</a></li><li><a href="https://linux.die.net/man/8/adduser">https://linux.die.net/man/8/adduser</a></li><li><a href="https://unix.stackexchange.com/questions/10852/whats-the-difference-between-sbin-nologin-and-bin-false">https://unix.stackexchange.com/questions/10852/whats-the-difference-between-sbin-nologin-and-bin-false</a></li><li><a href="https://www.baeldung.com/linux/create-non-login-user">https://www.baeldung.com/linux/create-non-login-user</a></li><li><a href="https://unix.stackexchange.com/questions/80277/whats-the-difference-between-a-normal-user-and-a-system-user">https://unix.stackexchange.com/questions/80277/whats-the-difference-between-a-normal-user-and-a-system-user</a></li><li><a href="https://serverfault.com/questions/350931/in-what-condition-should-i-create-a-system-user-instead-of-a-normal-user">https://serverfault.com/questions/350931/in-what-condition-should-i-create-a-system-user-instead-of-a-normal-user</a></li></ul><h3><strong>Follow My Journey on 100 Days of DevOps</strong></h3><p>This article is part of a series documenting my progress through KodeKloud’s 100 Days of DevOps challenge.</p><p><a href="https://kodekloud.com/100-days-of-devops">100 Days of DevOps | KodeKloud</a></p><p>Next Post: Day 2/100: <a href="https://medium.com/@kripalparsekar/day-2-100-temporary-user-setup-with-expiry-b79b62d79c65">Temporary User Setup with Expiry</a></p><p>Follow my #100DaysOfDevOps journey here on <a href="https://medium.com/@kripalparsekar/list/100-days-of-devops-1d3cf1958177">Medium </a>or connect with me on <a href="https://www.linkedin.com/in/kripalparsekar/">LinkedIn</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*fPzBispc6d2Nu68o.gif" /></figure><p>#100DaysOfDevOps, #Linux, #SysAdmin, #DevOps, #KodeKloud.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dff67c191754" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>