Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit 0941b75

Browse files
author
Guillaume Bernard
committed
fix: allow other ssh ports using selinux
Signed-off-by: Guillaume Bernard <[email protected]>
1 parent f0cbcc5 commit 0941b75

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

tasks/hardening.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@
7171
- ssh_challengeresponseauthentication
7272
- ssh_google_auth
7373

74-
- name: test to see if selinux is installed and running
75-
command: getenforce
76-
register: sestatus
77-
failed_when: false
78-
changed_when: false
79-
check_mode: no
80-
8174
- name: include selinux specific tasks
8275
include_tasks: selinux.yml
83-
when: sestatus.rc == 0
76+
when: ansible_selinux and ansible_selinux.status != "disabled"

tasks/selinux.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
state: present
1515
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
1616

17+
- name: "authorize {{ ssh_server_ports }} ports for selinux"
18+
seport:
19+
ports: '{{ item }}'
20+
proto: tcp
21+
setype: ssh_port_t
22+
state: present
23+
with_items:
24+
- "{{ ssh_server_ports }}"
25+
1726
- name: check if ssh_password module is already installed
1827
shell: 'set -o pipefail && semodule -l | grep ssh_password'
1928
args:
@@ -48,7 +57,7 @@
4857
- name: install selinux policy
4958
command: semodule -i {{ ssh_custom_selinux_dir }}/ssh_password.pp
5059

51-
when: not ssh_use_pam and sestatus.stdout != 'Disabled' and ssh_password_module.stdout.find('ssh_password') != 0
60+
when: not ssh_use_pam and ansible_selinux != 'Disabled' and ssh_password_module.stdout.find('ssh_password') != 0
5261

5362
# The following tasks only get executed when selinux is installed, UsePam is 'yes' and the ssh_password module is installed.
5463
# See http://danwalsh.livejournal.com/12333.html for more info

0 commit comments

Comments
 (0)