Score:19

Seeking an "operator present" indication for a remote system accessed over ssh

us flag

An elderly relative uses a Ubuntu 18.04 + LXDE desktop, mostly just for internet browsing and to play a few word games. They rarely shut the PC down...last time I checked, it had been turned on for over 15 days.

I administer the system remotely over ssh.

For the occasional time that I need to reboot the system, I'd like some means to determine if my relative is actively using it so that I don't disrupt them. I've done it in the middle of the night sometimes, but they sleep poorly and sometimes get up and play their games then.

Calling them on the phone works, but there are several time zones between us, and sometimes it wakes them up.

If they are playing a game, I can see that in top, but I can't find a way to tell if they are actively using the browser.

Some kind of mouse and/or keyboard activity indicator would be awesome, but I wish to stay away from any kind of keylogger type software. I suspect such a "mouse/keyboard activity detected" thing exists - to put the system to sleep / activate the screensaver** and wake it up if for nothing else - but I can't find it.

** I don't think they actually use a screensaver, that was just an example. I think the power manager just blanks the screen.

Is there a "time since last keyboard/mouse interaction from user" tracked somewhere?

Any solutions need to be do-able over ssh.

PonJar avatar
in flag
Could you search the browser cache for the most recent file and make a judgment from that?
Organic Marble avatar
us flag
@PonJar that might not cover the game-playing case.
David Z avatar
es flag
This is definitely beside the point, but 15 days isn't necessarily that long. E.g. I'm writing this comment from a KDE desktop that has been continuously up (and logged in) for 48 days and is totally fine. So if you ever want to reboot the computer _just_ because you feel like it's been up too long, it might be a perfectly reasonable solution to wait, and save the reboots for when you need to do major software updates or stuff like that.
Organic Marble avatar
us flag
@DavidZ yeah, I know people do different things. I only need to reboot it for kernel updates. The only reason I mentioned it staying on was to reinforce that if I don't reboot the thing, they never will.
Software Engineer avatar
de flag
10/10 for getting them on a GNU/Linux distro -- it's just so much easier to manage. To reinforce the reboot thing that David Z mentioned, I have my wife run Garuda GNU/Linux on the Dell ultrabook she uses for work and she hasn't had to reboot in months. We don't update it that often because it's not a server and so isn't much of a security risk. I'd say that your relative's machine probably doesn't need much maintenance either for the same reasons -- if it's working, just leave it alone.
Score:25
cn flag
jpa

There exists an utility to print the idle time of the X screen:

DISPLAY=":0" xprintidle

It prints the time since last keyboard or mouse input in milliseconds.


Another option would be to pop up a question box:

DISPLAY=":0" zenity --question --text="Organic Marble asks: Are you currently using this computer?" && echo yes

Then if you get no answer within a few minutes, just ctrl-c it out and proceed to reboot.

Organic Marble avatar
us flag
The interactive approach is one I had not thought of! Thanks! But the first one looks perfect. I will need to install the command and test it out.
cn flag
jpa
If you always get small idle times, it may be that they have a jittery optical mouse. Might also explain why the monitor is always on.
Organic Marble avatar
us flag
This looks perfect. I can do `expr $(DISPLAY=":0" xprintidle) / 60000` to get idle time in integer minutes. I just need to monitor it for a few hours and make sure that I see it go down before accepting.
Organic Marble avatar
us flag
Works a treat! Thanks for teaching me about `xprintidle`
Score:8
mx flag

If the monitor is configured to save energy, you may check it:

xset -display :0 q

Look at last line:

Monitor is Off
Organic Marble avatar
us flag
This looks very promising! I just tried it and got "Monitor is On". I'll keep checking and see if it ever goes off.
justhalf avatar
fr flag
@OrganicMarble so is it ever off?
Organic Marble avatar
us flag
@justhalf I've checked it several times over the last day. It has always shown 'on', so this solution may not work in my case.
Score:6
cn flag
raj

Well... this is only an idea, but if you login via ssh to the same user that your relative is using, set the DISPLAY environment variable to :1 and run xinput test n where n is the number corresponding to the mouse (you can obtain that number with xinput --list, in my case it's 9), then that command will print a line of text (in form like motion a[0]=338 a[1]=889) whenever the mouse is moved. So you can pipe the output from that command to some script that will record time when it last got any input, thus you will know when the mouse has been last moved (of course this has to run constantly in the background to record actual time of last mouse movement).

mckenzm avatar
in flag
If they are watching video there may not be mouse traffic? Keepalives tend to be a keyboard buffer hack?
Score:1
us flag

I think the only way you're going to know for absolutely sure is to "spy" on their screen.

  1. Install x11vnc on their computer with sudo apt-get install x11vnc net-tools

  2. (Optional) Create a shell script on their computer to automate the process of starting the server, so you don't have to remember the syntax every time. Note that the -auth parameter may need to be changed; I only have Fedora to test with right now, and Ubuntu might save the auth file in a different location.

#!/bin/sh
sudo x11vnc -auth /var/run/lxdm/lxdm-\:0.auth -display :0 -rfbport 5900 -localhost
  1. Install your favorite VNC viewer application on your computer.

  2. Set up SSH port tunneling for port 5900 on your computer. Assuming you're using OpenSSH, put the following in your .ssh/config file:

Host theirhostname
    LocalForward 5900 localhost:5900

When you want to actually look at their screen:

  1. SSH into their computer as normal.

  2. Run the shell script (or type out that big sudo x11vnc line).*

  3. Start your VNC viewer application, and direct it to connect to localhost.

Voila, you should be able to see their screen.

*Note: You're going to get several warnings that the VNC server isn't protected by a password. This isn't a security risk, since the VNC server port can only be accessed locally, meaning that any attacker would have to already be logged in. If you're really concerned, though, use x11vnc -storepasswd to create a password file, then add -rfbauth /home/user/.vnc/passwd to the x11vnc command line.

Organic Marble avatar
us flag
I am a regular user of VNC, but I need to be able to do this from my phone sometimes using only terminal capabilities. Thanks for a good suggestion that could work for someone else, +1.
HiddenWindshield avatar
us flag
@OrganicMarble I routinely use VNC to log in to my computer from my (android) phone, using a SSH app called Termius and a VNC client called VNC Connect. (There are others, of course, those are just the two I happen to use.)
Organic Marble avatar
us flag
Thanks. I also don't feel comfortable watching their screen without their permission, and if I have to ask for permission, they have to be there...
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.