I was using NFS tunneled over SSH successfully in Leap 15.6 but attempting to do the same thing in leap 16 I get errors such as my_tunnel.service: Unable to locate executable '/usr/bin/ssh': Permission denied
Service file looks like this:
@Richard_MQ likely, that is why if you use cockpit and install setroubleshoot-server it will provide details… or you can do the steps as detailed in Portal:SELinux - openSUSE Wiki
You need to decide whether you want to keep SELinux or not.
If you do, you have two options
Sledgehammer approach - allow init_t to use /usr/bin/ssh (i.e. add SELinux policy module with the correct rules). This probably could be generated by the audit2allow. This effectively defeats the purpose of the SELinux as it allows any service to run ssh, including for calling home.
Add new SELinux domain (context), make sure your service transitions into this domain when started and allow only this domain to execute /usr/bin/ssh. This is slightly more involved and needs more than poor man AI tools.
The more I look at the various problems people have with SELinux the more I agree that SELinux is far too complicated to be useful on a general purpose system and that the right thing is isolation (that systemd supports quite well).
Thanks, I understand your suggestions. As you say, (1) is defeating the object of SELinux. But indeed (2) looks like being a bit involved. I will try to do as you suggest in (2).
@Richard_MQ Sorry, I was mistaken. systemd does not explicitly transition a service to a SELinux domain, it relies on the magic during exec. While the target domain can be overridden with SELinuxContext, service binaries are launched while being in the default context (init_t) which means init_t must be allowed to execute binaries.
I tried to set init_t permission using sudo chcon -t init_t /usr/local/bin/* but get the response chcon: failed to change context of '/usr/local/bin/my_tunnel.sh' to ‘unconfined_u:object_r:init_t:s0’: Permission denied
ls -dZ /usr/local/bin/ reports unconfined_u:object_r:usr_t:s0 /usr/local/bin/
Any suggestions please how to fix this?
PS also tried as root following su -, no difference
When I restart the systemd service I don’t see any errors, but attempting to mount the remote directory fails saying mount was refused:
$ sudo mount -vvv localhost:/home/data/shared /home/shared
mount.nfs: timeout set for Sun Nov 30 15:58:17 2025
mount.nfs: trying text-based options 'vers=4.2,addr=::1,clientaddr=::1'
mount.nfs: mount(2): Connection refused
mount.nfs: trying text-based options 'vers=4.2,addr=127.0.0.1,clientaddr=127.0.0.1'
mount.nfs: mount(2): Connection refused
mount.nfs: trying text-based options 'addr=::1'
mount.nfs: prog 100003, trying vers=3, prot=6
This feels like a different problem, but essentially the same scripts are still working on my desktop machine with Leap 15.6, same server and SSH tunnel.
While it implies that you may have other problems, it should work for your particular case. I have shown you the working service and script.
Fix what? This?
I have never said to do it. Anyway, chcon is till not god almighty and what it does must be allowed by the current policy.
bor@leap16:~> sesearch -A -t init_t -c file -p relabelto
bor@leap16:~>
Nothing is allowed to relabel file to the init_t. The init_t is used for processes, not for files. The very first PID 1 transitions into init_t when kernel launches it.
Thank you for clarifying. Unfortunately this episode is increasingly convincing me that Leap 16 is not a great match for my use case, a great shame after so many years with S.u.S.E. 5.2 and its successors.
For now I will revert to my original manually started tunnel script (which still works), if I ever have time and inclination to learn SE Linux I might try again to automate it.