I'm trying to make a script to sent an alert when screen sharing is on.

The following command is supposed to list every established VNC connection but this doesn't return anything at all for me :

netstat -a | grep vnc | grep ESTABLISHED 

the only option I found to list past connection :

 log show --predicate 'processImagePath CONTAINS "screensharingd" AND
 eventMessage CONTAINS "Authentication"'

Any idea how to get current VNC session ? and even better, any idea how to sent an alert/email in the background each time a new connection is done

PS : just to make sure, Apple Screen-Sharing (from remote management) is using VNC protocol right?

  • this guy says this works -> stackoverflow.com/questions/4552312/…: lsof -a -i :vnc-server -sTCP:ESTABLISHED -c AppleVNCServer – mwm Apr 6 '20 at 23:40
  • How have you configured privacy settings and sharing settings? There are quite a few ways this data can leave macOS. Not all are VNC. – bmike Sep 18 '20 at 12:35

You must log in to answer this question.

Browse other questions tagged .