Tormak9970 / bash-shortcuts

A Steam Deck plugin for creating custom shortcuts that can be launched from the Quick Access Menu. Uses Bash under the hood.
Other
32 stars 8 forks source link

Trying to start/stop sshd #23

Open Karrq opened 1 year ago

Karrq commented 1 year ago

Hello, I recently got my hands on a new Steam Deck and I wanted to make system management and file transfer less painful without having to switch back and forth between desktop and gaming mode.

To that end, I wanted to enable/disable the SSH server service using this plugin, which is million times better then having a "Non-Steam Game" pointing to konsole etc.

My first attempt failed as I noticed sudo wasn't supported, premusably for the password input, so I had tried specifying over sudoers file to remove the password for the specific invocations I need, but I wasn't able to get it to work.

I realized I could normally start/stop service without sudo, but I'd be prompted for a password. I know the mechanism behind this is PolKit so I figured I could add a rule to allow management of the sshd.service unit without a password, and it worked - I'm able to manage sshd.service without being prompted for password, simply with systemctl start sshd.

So I tried creating 2 shortcuts, one to start and one to stop, with the appropriate invocations, but unfortunately when I attempt to use these they seem to keep running forever, without actually turning on (or off) the service.

Am I missing something? Thank you!

Tormak9970 commented 1 year ago

Hello, I recently got my hands on a new Steam Deck and I wanted to make system management and file transfer less painful without having to switch back and forth between desktop and gaming mode.

To that end, I wanted to enable/disable the SSH server service using this plugin, which is million times better then having a "Non-Steam Game" pointing to konsole etc.

My first attempt failed as I noticed sudo wasn't supported, premusably for the password input, so I had tried specifying over sudoers file to remove the password for the specific invocations I need, but I wasn't able to get it to work.

I realized I could normally start/stop service without sudo, but I'd be prompted for a password. I know the mechanism behind this is PolKit so I figured I could add a rule to allow management of the sshd.service unit without a password, and it worked - I'm able to manage sshd.service without being prompted for password, simply with systemctl start sshd.

So I tried creating 2 shortcuts, one to start and one to stop, with the appropriate invocations, but unfortunately when I attempt to use these they seem to keep running forever, without actually turning on (or off) the service.

Am I missing something? Thank you!

This should work, I'll do some testing as to why its not

Karrq commented 1 year ago

Thank you! I was wondering if there was a way or a place where the terminal output is stored? Or some kind of logging that we can look at to better diagnose issues like these

McSwindler commented 1 year ago

I was able to get this working. Here is my polkit rules file /etc/polkit-1/rules.d/49-sshd-nopassword.rules

polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.systemd1.manage-units" &&
        action.lookup("unit") == "sshd.service" &&
        subject.user == "deck") {
        return polkit.Result.YES;
    }
});

Shortcut is just systemctl start sshd and made sure to uncheck "Does this launch an app?" option.