2

Is there a way to remotely start a GNOME session without root via SSH?

Background

I am trying to access the CD drive (/dev/cdrom -> /dev/sr0) of a remote machine via SSH.

Remote machine is running Ubuntu 18.

The problem is that permission to write to the drive file (/dev/sr0) is set in a file ACL to the gdm user when no one is logged into the computer (can be verified with getfacl /dev/sr0).

When a user logs into the computer via GNOME (i.e., in person), then the ACL gets updated to match their user.

  • 1
    I don't think you're supposed to be able to do that. The idea is probably that only the locally logged user can access the CD drive. But anyways, has the user you log in via ssh any extra permissions (what does id say?). – mosvy Aug 21 at 17:21
1

If you're using a SSH connection with X11 forwarding enabled (and have a local X11 server running), you should be able to start a GNOME session on the remote server by using the command gnome-session.

But you'll find that won't give you access to the CD drive.

You see, the CD drive permissions are granted to a locally logged-in user only, even if the login is done in text mode on a virtual console. Not to simply whoever is having a GNOME session. The system will know the difference. The ACL assignment is done by udev: the uaccess tag assigned to devices in /lib/udev/rules.d/70-uaccess.rules will determine which devices will get this treatment.

If you want to have the capability to use the CD drive while logged on remotely over SSH, your user account needs to have the cdrom group membership assigned to it. That needs to be done only once, but it requires root access. For example, if your user account is named helper:

sudo usermod -a -G cdrom helper

or

sudo gpasswd --add helper cdrom

or

sudo adduser helper cdrom

After any one of those commands is executed, you'll need to log out to make the change effective. On your next login, you'll be a member of the cdrom group (in addition to whatever group(s) you were member of before) and can always use the CD drive, whether you're logged in locally or remotely. That's what the cdrom group is for.

Other groups with similar purposes are listed here: https://wiki.debian.org/SystemGroups

  • I assume that the "without root" from the OP's Q means no sudo either. Otherwise they could just mount the cd and be done with the whole thing. – mosvy Aug 21 at 17:36
  • Yes, in order to be able to use the CD drive remotely, someone with root privileges needs to grant permission. – telcoM Aug 21 at 18:45
0

I do this with the MATE desktop by starting Xnest at :1 and a smaller-than-full-screen resolution. I then do an export DISPLAY=:1 and then ssh -Y user@remotehost mate-session and I get my full desktop in the smaller Xnest X "server" window. (Xnest at this point is acting as both a X server and X client)

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.