Results 1 to 5 of 5
Hey i'm pretty new at Linux, but I'm picking it up very quick. I am currently using Fedora
However i am in need of some help
I need to be ...
- 07-16-2011 #1Just Joined!
- Join Date
- Jul 2011
- Posts
- 3
Need to make a script
Hey i'm pretty new at Linux, but I'm picking it up very quick. I am currently using Fedora
However i am in need of some help
I need to be able to write a script that goes into my process's and will look at see if anyone else besides me is logged into my computer through gaining remote access, and once it has identified if someone is indeed on my computer or not i need the script to then kick them off.
by the way i am going to need to use Bash in order to script all of this out
can anyone please help me out? thanks!!
- 07-17-2011 #2
Searching for "linux force logoff" brought me to this:
Achmad Z's Archives: Linux: Force disconnect/logoff/logout user
Note that the script would need to be run as root.DISTRO=Arch
Registered Linux User #388732
- 07-17-2011 #3Just Joined!
- Join Date
- Jan 2011
- Location
- Fairfax, Virginia, USA
- Posts
- 94
Hi, I dont know if this helps or not but I have some input. First its best (in my option which may be wrong) to restrict external access to your machine to ssh only. You can use the chkconfig program to check this. Once your sure ssh access is the only way in, you can edit this file as root:
/etc/ssh/sshd_config
and add this line to the bottom of the file:
AllowUsers brian
Were "brian" is replaced with your login name. This will prevent others from logging into your system. If you want to allow several users into your system through ssh, your line would look like this:
AllowUsers brian root jeff ted
- 07-17-2011 #4Just Joined!
- Join Date
- Mar 2011
- Location
- NH
- Posts
- 14
"users"
I'll assume that this is an exercise, as BrianMicek says restricting access in the first place is easier. However, I guess we can assume that you have created accounts for other people, so you want them to have access.
The "users" command will list logged in users. Without looking up all the commands for you, the logic you want is:
1 - Get list of users (hint, write to text file)
2 - Set variable with my user name
3 - Iterate through list of users (ok, a bit more than a hint here)
while read line; do
compare with your user name here
done < "$filename"
4 - Compare user with "me".
5 - If not me, force logoff
6 - Goto 3
- 07-17-2011 #5Just Joined!
- Join Date
- Feb 2011
- Posts
- 83
Try with who -u (it will show you who where is logged); identify yourself (AsCommonUser or Root at tty1; pts/0 etc.) and kill the other processes.
For further details see: # who --help


Reply With Quote
