I know it sounds funny. I wrote a shell script and executed on a remote machine to ssh back to my local machine to write some files. I executed the script on various remote machines and I can't remember where they are. Now I can't kill one or more of them because I forgot which machine(s) it/they are on and they are continuously creating new files on my local machine. So is there any way to see which remote machine is accessing my local file? I'm running a Debian OS and I do NOT have root access.

EDIT: I tried remove the affected files but as soon as I remove them new files are created by the script running on the remote machine(s). I also tried chmod 000 to make the directory un-writable in hope of crashing the scripts. None of them works.


All ssh login attempts should be logged in /var/log/auth.log, examining that file may help you find those remote machines.

  • Finally I managed to kill all the scripts running on all the machines. Thanks. – YankeeWhiskey Feb 5 '13 at 20:11

You could do

$ while true; do netstat -an | grep \:22 |  cut -b45-90 | grep -v \:22 | grep ESTABLISHED >> watch22.txt; sleep 5; done 

So this will put any port 22 connections into a file that originated off the box, which will get pretty big pretty quick as it will keep adding the same connections when nothing is happening. But if you run it for a long enough duration you'll catch the culprits:


And you can filter this down pretty easily to a list of unique IPs:

$ cat watch22.txt | cut -d\: -f1 | sort -u

I would like to recommend the simple utility whowatch. It will show you the users logged on to the system(which it is executed on). From there you can select the user (will say "sshd" if using ssh) and kill/interrupt the main process in the tree (disconnecting the session)-but this requires root.

With whowatch however you will be able to easily see who is logged on to who and using what.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.