You are not logged in.

#1 2019-11-19 03:36:31

alexia-v2
Member
Registered: 2019-10-10
Posts: 13

installing selinux breaks OpenSSH

I've setup SELinux as per the wiki (minus editing a python script to fix a syntax error and a PKGBUILD to prevent it recloning the bad repo with the bad script)
However when I `setenforce 1` I get kicked off my SSH connection. Any attempts to reconnect immediately disconnect on connection
Unfortunately I don't have physical access (cloud hosted server) so I have to reboot to get back in. However I can verify a web application running on the server still runs so it doesn't go down completely when I can't login
Is there a way to get SSH connection working with SElinux? SElinux seems to be by far the best security solution, especially for a remotely administered server

Offline

#2 2019-11-19 05:05:37

g2g591
Member
Registered: 2007-12-24
Posts: 54

Re: installing selinux breaks OpenSSH

leave it in permissive mode, look at the logs and plugging it into something like audit2allow. Only set it to enforcing once you're not getting denials from ssh related things (and other potentially important things)

Offline

#3 2019-11-19 08:57:10

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,710
Website

Re: installing selinux breaks OpenSSH

Are you still using Zen or Arch Linux now?
In the latter case, please provider your /var/log/audit/audit.log.


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#4 2019-11-19 12:01:40

alexia-v2
Member
Registered: 2019-10-10
Posts: 13

Re: installing selinux breaks OpenSSH

I hope you have a hearty machine, it's long. /var/log/audit is empty, I got the log via 'journalctl|grep denied > audit.log'

Btw this is a completely different server - that was my PC (which used the zen **installer** for arch Linux, primarily because the network I regularly use requires browser sign-in)

https://transfer.sh/Wgnn2/audit.lo

Offline

#5 2019-11-19 12:13:42

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,710
Website

Re: installing selinux breaks OpenSSH

1) The file cannot be found on the server.
2) Please do not pre-filter the output.


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#6 2019-11-19 12:23:12

alexia-v2
Member
Registered: 2019-10-10
Posts: 13

Re: installing selinux breaks OpenSSH

schard wrote:

1) The file cannot be found on the server.
2) Please do not pre-filter the output.

So....you'd rather me posted the entire output of journalctl?

Offline

#7 2019-11-19 16:03:47

loqs
Member
Registered: 2014-03-06
Posts: 19,097

Re: installing selinux breaks OpenSSH

I would suggest limiting journalctl output to one affected boot.

Offline

#8 2019-11-20 02:31:03

alexia-v2
Member
Registered: 2019-10-10
Posts: 13

Re: installing selinux breaks OpenSSH

@g2g591 no go
Audit2allow returns

Traceback (most recent call last):                        File "/usr/bin/audit2allow", line 25, in <module>         import sepolgen.audit as audit                        File "/usr/lib/python3.8/site-packages/sepolgen/audit.py", line 24, in <module>                                   from . import access                                  File "/usr/lib/python3.8/site-packages/sepolgen/access.py", line 37, in <module>                                  from selinux import audit2why                       ImportError: cannot import name 'audit2why' from 'selinux'

Offline

#9 2019-11-21 11:37:19

g2g591
Member
Registered: 2007-12-24
Posts: 54

Re: installing selinux breaks OpenSSH

alexia-v2 wrote:

@g2g591 no go
Audit2allow returns

Traceback (most recent call last):                        File "/usr/bin/audit2allow", line 25, in <module>         import sepolgen.audit as audit                        File "/usr/lib/python3.8/site-packages/sepolgen/audit.py", line 24, in <module>                                   from . import access                                  File "/usr/lib/python3.8/site-packages/sepolgen/access.py", line 37, in <module>                                  from selinux import audit2why                       ImportError: cannot import name 'audit2why' from 'selinux'

Install selinux-python (AUR) . Believe that should contain the needed bits.

Last edited by g2g591 (2019-11-21 11:38:42)

Offline

#10 2019-11-21 15:05:57

alexia-v2
Member
Registered: 2019-10-10
Posts: 13

Re: installing selinux breaks OpenSSH

g2g591 wrote:
alexia-v2 wrote:

@g2g591 no go
Audit2allow returns

Traceback (most recent call last):                        File "/usr/bin/audit2allow", line 25, in <module>         import sepolgen.audit as audit                        File "/usr/lib/python3.8/site-packages/sepolgen/audit.py", line 24, in <module>                                   from . import access                                  File "/usr/lib/python3.8/site-packages/sepolgen/access.py", line 37, in <module>                                  from selinux import audit2why                       ImportError: cannot import name 'audit2why' from 'selinux'

Install selinux-python (AUR) . Believe that should contain the needed bits.

Still no go, was already installed

Offline

#11 2019-11-22 09:02:52

g2g591
Member
Registered: 2007-12-24
Posts: 54

Re: installing selinux breaks OpenSSH

alexia-v2 wrote:
g2g591 wrote:
alexia-v2 wrote:

@g2g591 no go
Audit2allow returns

Traceback (most recent call last):                        File "/usr/bin/audit2allow", line 25, in <module>         import sepolgen.audit as audit                        File "/usr/lib/python3.8/site-packages/sepolgen/audit.py", line 24, in <module>                                   from . import access                                  File "/usr/lib/python3.8/site-packages/sepolgen/access.py", line 37, in <module>                                  from selinux import audit2why                       ImportError: cannot import name 'audit2why' from 'selinux'

Install selinux-python (AUR) . Believe that should contain the needed bits.

Still no go, was already installed

Well, some selinux related python bit seems to be missing... If your heart is set on selinux, it may be better to try out a distro where it's officially supported rather than the barebones reference policy which apparently isn't properly set to allow ssh.

Anyway, back to Arch, ensure policycoreutils is installed (thats the package audit2allow comes in on other distributions) and look at its optional dependencies and see if installing one of them makes it work.

Offline

#12 2019-11-22 18:44:01

alexia-v2
Member
Registered: 2019-10-10
Posts: 13

Re: installing selinux breaks OpenSSH

g2g591 wrote:
alexia-v2 wrote:
g2g591 wrote:

Install selinux-python (AUR) . Believe that should contain the needed bits.

Still no go, was already installed

Well, some selinux related python bit seems to be missing... If your heart is set on selinux, it may be better to try out a distro where it's officially supported rather than the barebones reference policy which apparently isn't properly set to allow ssh.

Anyway, back to Arch, ensure policycoreutils is installed (thats the package audit2allow comes in on other distributions) and look at its optional dependencies and see if installing one of them makes it work.

In a couple of days I'm going to set up a vm with arch to try screwing with sepolicy but for now switched to a different distro on my production servers. Will get back to you once I get it set up

Offline

Board footer

Powered by FluxBB