π What is a Non-Interactive Shell?
A non-interactive shell is used to create a user account without login access.
This is commonly used for:
Service accounts
Application users
FTP-only users
Security hardening
Such users cannot log in via SSH or access the system shell.
π« Common Non-Interactive Shell Paths
Depending on the Linux distribution, you can use:
/sbin/nologin
/usr/sbin/nologin
/bin/false
These shells prevent interactive login.
π₯οΈ Entering the Server (SSH Access)
To connect to a Linux server:
ssh {user}@{ip-address}
Example:
ssh james@172.16.238.11
π€ Creating a User with Non-Interactive Shell
To add a user without login access:
sudo useradd -s /sbin/nologin {username}
Example:
sudo useradd -s /sbin/nologin appuser
This will:
Create the user
Set shell to /sbin/nologin
Prevent SSH login
π Verify the Userβs Shell
You can check the assigned shell using:
cat /etc/passwd | grep appuser
Output example:
appuser:x:1002:1002::/home/appuser:/sbin/nologin
π― Best Practice
Use non-interactive shells for service accounts
Do NOT allow unnecessary SSH access
Follow the principle of least privilege