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?

2
  • 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
    Commented Aug 7, 2015 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? Commented Aug 7, 2015 at 22:03

1 Answer 1

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...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .