2

I will sometimes remote into my work computer from home using TeamViewer. Obviously I have to unlock the screensaver to use the GUI.

When I'm done, I'll lock the screen either from the desktop or via an ssh command.

However, during that time, suppose a maintenance worker comes into my office, physically removes the ethernet cable (or otherwise permanently interrupts my connection), and has an unlocked desktop?

Is there a simple way to automatically run the screen lock command if the computer detects that it has lost its internet connection? Preferably, it would not re-arm itself until connectivity is restored.

I don't mind if this means a quick network outage while at work causes my screen to lock. I'll just unlock the screen and keep working, sans internet.

Is there a service out there already for this? Or should I just have a cron job run every minute, making sure it can ping 'google.com', and run the 'lock' script if ping fails?

  • Run a poor-man's network monitor in a minimized xterm and lock the screen if network connectivity fails? Eg. while true; do ping -c3 foo.example.org || xscreensaver-command -lock; sleep 3; done – ckujau Aug 7 '15 at 0:20
  • Why would you unlock your work computer's screen to use the GUI? This sounds either like an XY problem or like you're trying to work around a Windows limitation (single user at a time) which doesn't exist on Unix systems. What OS is the remote system running? – Gilles 'SO- stop being evil' Aug 7 '15 at 22:03
3

If your system is running systemd, you could create a unit which would trigger when the network interface goes down which would lock your screen in the simple case where the machine is physically unplugged from the network. But you want your work computer to verify that you are still connected to your work computer, not merely that your work computer can reach some subset of the network / Internet. A better approach would be checking TeamViewer for options to monitor the connection from end-to-end and trigger an action (locking the screen) if the connection is dropped. If your information is truly sensitive enough to worry about this scenario, another (much more secure) option would be to forward the display over an encrypted connection without ever unlocking the work computer screen. Of course, the work computer must be physically secured and use proper encryption...

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.