1825805 Members
2585 Online
109688 Solutions
New Discussion

Re: disconnect a user

 
Greta Blamire
Frequent Advisor

disconnect a user

Hi,
I need some help with a shell script I'm writing. How do you disconnect a user? This script is to keep users from getting to the command line. If they sign on, the script should tell them to use the other interface then disconnect them.
Thanks in advance!
If you can't face the facts, change them!
6 REPLIES 6
A. Clay Stephenson
Acclaimed Contributor

Re: disconnect a user

If the "other interface" is an application then simply make that application the startup program in the passwd file and your users will never see the shell or make their startup program something like /usr/bin/false.

The other simple answer is
in their .profile

trap '' 0 1 2 3 15

echo "Do not use the shell"
sleep 5
exit 0
If it ain't broke, I can fix that.
Pete Randall
Outstanding Contributor

Re: disconnect a user

Something like this perhaps?

ps -ef | grep ' '$USERNAME' ' | grep -v "resetuser" | awk '{ print $1,$2 }'
> /tmp/reset.tmp
PROCESSES=`grep $USERNAME /tmp/reset.tmp | awk '{ print $2 }' | sort -n`
for PROC in $PROCESSES
do
echo "\tKilling process $PROC"
kill $PROC
done



Pete

Pete
Pete Randall
Outstanding Contributor

Re: disconnect a user

Sorry - missed the USERNAME in my cut and paste:

USERNAME=$1


should be at the beginning.

Pete

Pete
Deshpande Prashant
Honored Contributor

Re: disconnect a user

HI
Call the script/menu you need from users .profile with last line as "exit 0"

or make that script/program as a start-up shell for the user.

Thanks.
Prashant.
Take it as it comes.
James R. Ferguson
Acclaimed Contributor

Re: disconnect a user

Hi Greta:

I think the better approach is to make their startup script the "other interface" rather than a shell.

You can do this by substituting the script or executable for a shell in '/etc/passwd'.

You can also do this by 'exec'ing the interface as the last statement in the user's profile:

exec $HOME/interface

The first method is more rigorous in most cases.

Regards!

...JRF...
Greta Blamire
Frequent Advisor

Re: disconnect a user

The interface that all users should use is a seperate thin client application. This is just insurance if someone starts exploring and manages to telnet in. Clay's script works great, just cut them off immediately. Thanks Again!
If you can't face the facts, change them!