Create a Linux User with non-interactive shell

Ticker

6/recent/ticker-posts

Create a Linux User with non-interactive shell

Question :  Create a Linux User with a non-interactive shell The System Admin Team of XfusionCorp Industries has installed a backup agent tool on all app servers. As per the tool's requirements, they need to create a user with a non-interactive shell. 



In this article, we'll discuss a way to create new user with non-interactive shell using the useradd command.

useradd may be a low level utility for adding users. On Debian, administrators should usually use adduser(8) instead.

Most of them task got fail because of there's no bin file exist in path /bin/nologin

For non interactive user you'll used 2 options below

  • /sbin/nologin is specifically designed to switch a shell and produces output complaining you cannot log-in.
  • where as /bin/false doesn't give output
-s, --shell SHELL
The name of a replacement user's login shell. this feature sets the SHELL variable in /etc/default/useradd.


Server Name

IP

Hostname

User

Password

Purpose

stapp01

172.16.238.10

stapp01.stratos.xfusioncorp.com

tony

Ir0nM@n

App 1

stapp02

172.16.238.11

stapp02.stratos.xfusioncorp.com

steve

Am3ric@

App 2

stapp03

172.16.238.12

stapp03.stratos.xfusioncorp.com

banner

BigGr33n

App 3




Solution:  

1. At first login to the respective mentioned server in the task. Mine is stapp02

thor@jump_host /$ ssh steve@stapp02

The authenticity of host 'stapp02 (172.16.238.11)' can't be established.

ECDSA key fingerprint is SHA256:NgyY+fBF5b56d9UEyUmbNHqK7eZTbk5n5/Ypr19rQkk.

ECDSA key fingerprint is MD5:ef:d2:32:cb:57:6f:44:cb:0c:0b:4f:82:f0:dc:92:70.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'stapp02,172.16.238.11' (ECDSA) to the list of known hosts.

steve@stapp02's password:

[steve@stapp02 ~]$

[steve@stapp02 ~]$ sudo su -

 We trust you have received the usual lecture from the local System

Administrator. It usually boils down to these three things:

     #1) Respect the privacy of others.

    #2) Think before you type.

    #3) With great power comes great responsibility.

 [sudo] password for steve:

[root@stapp02 ~]# 

2.  1st check user is existed on the server  by below command    

[root@stapp02 ~]# id ravi

id: ravi: no such user

[root@stapp02 ~]#


3.  If the user is not found the then you create a user with a non-interactive shell    

[root@stapp02 ~]# adduser ravi  -s /sbin/nologin

[root@stapp02 ~]#

4.  Validate user is created successfully as per the task request.      

[root@stapp02 ~]# id ravi

uid=1002(ravi) gid=1002(ravi) groups=1002(ravi)

 [root@stapp02 ~]# cat /etc/passwd |grep ravi

ravi:x:1002:1002::/home/ravi:/sbin/nologin

[root@stapp02 ~]#


5.  Click on Finish & Confirm to complete the task successful

Happy Learning!!!!

Apart from this if you need more clarity,  I have made a  tutorial video on this , please go through and share your comments. Like and share the knowledge 




 


Post a Comment

6 Comments

  1. is there no voice on the video? I am unable to hear if there's any explanation given.

    ReplyDelete
    Replies
    1. Thanks for your comments, I will soon start video with voice

      Delete
  2. [sudo] password of banner:
    how i find the password?

    ReplyDelete
    Replies
    1. I have mentioned password in page. Please used the same

      Delete
  3. I have performed the same but still task is showing as incomplete or failed..not sure why

    ReplyDelete
    Replies
    1. Have you run the command on correct app server given in your task. Please read the task correctly hostname and user might be change

      Delete

Latest Posts

KodeKloud Kubernetes Security CKS  Lab Challenge 4 |  Audit-policy | Install & configure falco utility | Inspect the API server audit logs and identify the user