1855702 Members
8518 Online
104103 Solutions
New Discussion

Re: Disable/Enable login

 
SOLVED
Go to solution
Helen French
Honored Contributor

Disable/Enable login

Hi,

Is there any way to disable (any user) logging in to the system ? I don't want to use the single user mode. And needs to re-enable this after some time.

Suppose my server is online and 10 users are logged in right now. I want to disable new logging in for 2 hrs. The users who are logged in will continue working. And after 2 hrs i want to enable this back so that everybody can use the system. In another words, the server should be virtually unavailable for 2 hrs to everybody.

Any type advices would be appreciated.

Thanks!
Shiju
Life is a promise, fulfill it!
8 REPLIES 8
Craig Rants
Honored Contributor
Solution

Re: Disable/Enable login

You could use /etc/nologin, here is a link that provides some background.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x5e730b0717d1d5118ff40090279cd0f9,00.html

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x5e06670142b2d5118ff10090279cd0f9,00.html

Or you could write your own little script that would work similar to nologin.

GL,
C
"In theory, there is no difference between theory and practice. But, in practice, there is. " Jan L.A. van de Snepscheut
Sridhar Bhaskarla
Honored Contributor

Re: Disable/Enable login

Hi Shiju,

You can keep a small script in your /etc/profile (and the corresponding files for other shells) to check for only few users or no users so that they can't get in.

if [ $LOGNAME != "YOU" ]
then
echo "keep out for sometime"
exit
fi

You can login as yourself and do the maintenance.

It will restrict telnet and rlogin but not ftp or rcp.

Does this help you?.

-Sri

You may be disappointed if you fail, but you are doomed if you don't try
Joseph C. Denman
Honored Contributor

Re: Disable/Enable login

Hi Shiju,

I don't know what services your clients a using, but you could stop inetd.

/sbin/init.d/inetd stop

Connected users are not affected, but no one else can...lets say telnet in.

...jcd...
If I had only read the instructions first??
Jeff Machols
Esteemed Contributor

Re: Disable/Enable login

you could just put exit as the last line in /etc/profile
Uday_S_Ankolekar
Honored Contributor

Re: Disable/Enable login

Helen French
Honored Contributor

Re: Disable/Enable login

Hi,

Thanks everybody ..btw, what does /etc/nologin do? just displaying the message ? what will happen if that file doesn't exist?

Thanks!
Shiju
Life is a promise, fulfill it!
Helen French
Honored Contributor

Re: Disable/Enable login

what would i do if i need to restrict ftp and rcp too?

Thanks!
Life is a promise, fulfill it!
Jeff Machols
Esteemed Contributor

Re: Disable/Enable login

you could always write a wrapper to /usr/bin/login, if you not root exit. Just be carefull to test so you don't lock yourself out! I am pretty sure ftp uses that to authenticate also. The /etc/nologin is part of the os on Sun and AIX, the threads posted basically mimic that functionality, it checks for a file, if it exists, output the message and exit the login, otherwise continue. On the other Unix platforms, this is done in the login script, you could always write a wrapper to that, just be aware if you