Create a Linux User with non-interactive shell!

ive ssh ed into the app1 and created a user
but it says the task is failed
it says

  • user ‘jim’ does not have non-interactive shell on stapp01

can some one help me

• useradd username -s /sbin/nologin

and they are asking you to create user with non-interactive shell but you created user with interactive shell

1 Like

Thank you Roopal mishra for the help .

Hello @roopal.mishra , my task was marked as failed.

I created the user using
sudo adduser javed -s /sbin/nologin.
Also Checked it using getent passwd javed.

Hello Team, Any input from team related to above issue. Thanks

Hi @anusharma0426 ,
Can you please try again? I didn’t see any problems.

Regards,

Could you let me know if you corrected anything after submitting the task?

This command as roopal says should work

• useradd username -s /sbin/nologin

The koudkloud labs works with a centos distro, so it is a redhat base distribution. In some cases, searching from the internet you can also find the command adduser, but this should work for ubuntu based distros. So in any case you are using the second one, will not work.

Another way to troubleshoot and probably fix this is by checking the /etc/passwd file. There you can see all the users and some configurations for the systems. The configs parameters are separated by a “:” . You may find some programs names over that file, because it’s Unix and everything is a file (Is because some programs also have user name for the system to do some stuff). So in /etc/passwd you can check and found your user and then search for /bin/bash (or any other linux shell), or /bin/nologin.

If you see /bin/bash it means that the system is working with a shell for your user, you can change it to /bin/nologin. Wich is a more hacking way to do the same stuff. Or at least you can see the file and troubleshoot the issue.

So, in order to do this you need to do this steps:

   * useradd "theUsernameNeddedWithouthTheDoubleQuotes" -s /sbin/nologin
   * sudo vi /etc/passwd              // You can also use nano or some editor, but you need sudo 
   * Find your user and change the last part to /bin/nologin
   * save the file and exit
   * sudo systemctl daemon-reload           // Reload all the configs files for the daemons, so you update to the new parameters from the configs files to the system.

That in theory should work, in case something else as you said is broken. Let me know if you succeed.