LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-07-2008, 11:17 PM   #1
nthillaiarasu
Member
 
Registered: Nov 2007
Posts: 39

Rep: Reputation: 15
Locking out non-root users while the system is in maintenance


To disable all user logins (except for root) without taking down the system into maintenance mode create a file in the location /etc/nologin.
The content of this file will be displayed when a user tries to log in. Useful when doing service on the system which might affect users.

Steps to do:
1.Go to terminal login as sudo user inorder to create file in /etc.
lostwarrior@leo:~$ --usermode

lostwarrior@leo:~$ sudo -s
[sudo] password for lostwarrior:
root@leo:~#

2.Once u login as root in terminal type cd /etc

3.type touch nologin
Now the user cant able to enter into the machine.If he enters the username then the content from nologin file will get displayed

4.NoteBefore doing this try to have the root password.Otherwise u cant enter into the root access.

5.For creating root password.1.Go to terminal login as sudo user

warrior@leo:~$ --usermode
lostwarrior@leo:~$ sudo -s
[sudo] password for lostwarrior:
root@leo:~#
6.now type passwd root (herepasswd is the command and root is the user)

7.enter the new password for root.

root@leo:/etc# passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@leo:/etc#
Note:This has been tested under ubuntu 7.10
 
Old 05-08-2008, 02:27 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
If the file /etc/nologin exists, login will allow access only to root. Other users will be shown the contents of this file and their logins will be refused.

Quote:
Steps to do:
1.Go to terminal login as sudo user inorder to create file in /etc.
lostwarrior@leo:~$ --usermode
OK:

~$ --usermode
bash: --usermode: command not found

I think you left something out...

Quote:
3.type touch nologin
Now the user cant able to enter into the machine.If he enters the username then the content from nologin file will get displayed
... hmmm, an empty file... niiice.

Hey! I'm locked out!
Quote:
4.NoteBefore doing this try to have the root password.Otherwise u cant enter into the root access.
Now he tells me!

How about just start with:

0. enable root login.

1. sudo nano /etc/nologin

Add text:

My Apologies;
This system has been locked for maintenance.
Anormal service will resume at 2300 hours.
--The MGT



Now you have a two-step howto, instead of 7.

BTW: Put "HOWTO" in the title next time.
 
Old 05-09-2008, 07:42 AM   #3
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Rep: Reputation: 164Reputation: 164
nthillaiarasu,

Good job. I learned something new today.

Simon. Thanks for the cleanup/clarification.
 
Old 05-09-2008, 09:12 AM   #4
SlowCoder
Senior Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Debian based
Posts: 1,250

Rep: Reputation: 164Reputation: 164
I decided to play with this a *very little*. I created /etc/nologin with some gibberish in Ubuntu. Guess what? I was still able to log in with my user account. Maybe this is due the fact that you can't directly log into Ubuntu as root, or maybe it's because I'm logging in via GUI. So, it's not a 100% case.
 
Old 05-09-2008, 09:55 AM   #5
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Rep: Reputation: 31
That's because /etc/nologin works only when login(1) is involved.
 
Old 05-09-2008, 11:06 AM   #6
Hangdog42
LQ Veteran
 
Registered: Feb 2003
Location: Maryland
Distribution: Slackware
Posts: 7,803
Blog Entries: 1

Rep: Reputation: 422Reputation: 422Reputation: 422Reputation: 422Reputation: 422
Isn't it just a lot easier to move to runlevel 1? You know telinit 1, do your maintenance work, then telinit 3 (or whatever your normal runlevel is).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Give root password for maintenance mijohnst Linux - General 5 12-29-2010 10:07 AM
SuSE 9.3 - USB Diapeared & Non-Root users can shutdown system nuro305 SUSE / openSUSE 9 04-14-2006 02:27 PM
System maintenance FictionPimp Linux - Newbie 2 02-01-2005 02:04 PM
Whats the difference between all the crontabs (system, root, users) ? glenn69 Linux - Newbie 2 10-12-2004 07:41 PM
System maintenance tied2 Linux - General 1 07-02-2002 11:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 04:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration