Run startx over SSH

2

This question has been asked several times, but the solutions I've found always solve the problem in a different way.

On the remote machine (the one on which I want to run startx), I have already

echo allowed_users=anybody | sudo tee /etc/X11/Xwrapper.config

When I ssh to the machine and run startx;, I get the error,

Fatal server error:
(EE) parse_vt_settings: Cannot open /dev/tty0 (Permission denied)

I added myself to the tty group after which the error is

Fatal server error:
(EE) xf86OpenConsole: Cannot open virtual console 2 (Permission denied)

Speculating, when I log in to the machine locally, getty (running as root) assigns ownership of tty0 to my user, and this is sine qua non. How can I make this assignment happen without typing my username and password on that virtual terminal? Maybe I can send keystrokes to the virtual terminal? Maybe I can chown the right files so that I can own it?

Of course this is a "XY" problem. The real problem is: when I'm away, I would like to log into the machine (e.g. after a reboot) and turn on its monitor (a projector in this case) so that my family can watch movies on my profile without knowing or having to type my password.

Limited Atonement

Posted 2019-04-30T14:55:41.263

Reputation: 224

I dont think using ssh would help, even after the permissions problem is solved. Something like VNC (server launched on startup) might be a better fit. The problem is even if you do get your ssh solution working I posit it will send the screen over the SSH connection, not to both the ssh connection and console. (Also, you probably dont have X forwarding set on the client side) – davidgo – 2019-04-30T19:15:38.957

@davidgo Thanks for the comment. I don't want X forwarding over SSH. I want X to take control of TTY0 just like it would if I typed my credentials in there and ran startx;. – Limited Atonement – 2019-05-01T19:29:55.040

Can you lunch startx by changing the runlevel (ie runlevel 5)? Relatedly, why does your system not start X on startup and how is it configured to not do so? – davidgo – 2019-05-01T20:09:36.187

I use arch linux. The default is not to start X unless specifically configured to do so. I don't run a desktop manager either. Run level...interesting. I don't know how that will help me give control of tty0 to X, but I'd be interested in hearing a more concrete suggestion! – Limited Atonement – 2019-05-03T01:58:43.780

I've never used arch, but have a look at https://wiki.archlinux.org/index.php/SysVinit#Runlevel_invocation

– davidgo – 2019-05-03T02:17:35.090

Answers

1

I hit this exact same problem and was able to get past it with sudo chmod g+r /dev/tty3. But I don't fully understand it, so YMMV.

Adam Bliss

Posted 2019-04-30T14:55:41.263

Reputation: 111

Wow, great idea! How did you decide to do this? You just looked at the permissions and noted that "r" permission was missing and gave it a shot? I'll have to try that next time! – Limited Atonement – 2019-12-03T13:49:15.660

1Yes, precisely. When I got the first "permission denied" error, I ran ls -l on the file, which revealed that it was owned by the group tty, which I added myself to, just as you did. When the error message changed, I looked harder at the group permissions, and noticed it had the g+w bit but not the g+r bit set. I don't know why, or what the broader implications are of setting it with chmod, or whether it will stick. – Adam Bliss – 2019-12-03T18:15:40.037

I assume a restart will reset the permissions (because /dev/tty* are virtual files put there by the kernel), but that's not a big deal. I can add the permission change to whatever script I use to do this in the future. Thanks! – Limited Atonement – 2019-12-04T03:09:24.300