How can I know if the user is connected to the local machine via ssh in my python script?
Am I correct in assuming you're running your script on some sort of UNIX/Linux system?  If so, you can just type "users" on the command-line, and it will show you the currently logged in users.
Also, if you call the "lastlog" command, that will show you all the users on the system and the last time they all logged in to the machine.
How can I know if the user is connected to the local machine via ssh in my python script?