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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-16-2011 #1
- Join Date
- Jul 2011
Need to make a script
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
- 07-17-2011 #3
- Join Date
- Jan 2011
- Fairfax, Virginia, USA
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:
and add this line to the bottom of the file:
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 #4
- Join Date
- Mar 2011
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 #5
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