|
|
c862b5 |
From be529f2ca1f3644db9ad436dbd35aa00a9a5cf14 Mon Sep 17 00:00:00 2001
|
|
|
c862b5 |
From: Watson Sato <wsato@redhat.com>
|
|
|
c862b5 |
Date: Wed, 13 May 2020 20:49:08 +0200
|
|
|
c862b5 |
Subject: [PATCH 1/2] Add simple tests for sshd_set_max_sessions
|
|
|
c862b5 |
|
|
|
c862b5 |
---
|
|
|
c862b5 |
.../sshd_set_max_sessions/tests/correct_value.pass.sh | 11 +++++++++++
|
|
|
c862b5 |
.../sshd_set_max_sessions/tests/wrong_value.fail.sh | 11 +++++++++++
|
|
|
c862b5 |
2 files changed, 22 insertions(+)
|
|
|
c862b5 |
create mode 100644 linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/correct_value.pass.sh
|
|
|
c862b5 |
create mode 100644 linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/wrong_value.fail.sh
|
|
|
c862b5 |
|
|
|
c862b5 |
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/correct_value.pass.sh b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/correct_value.pass.sh
|
|
|
c862b5 |
new file mode 100644
|
|
|
c862b5 |
index 0000000000..a816eea390
|
|
|
c862b5 |
--- /dev/null
|
|
|
c862b5 |
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/correct_value.pass.sh
|
|
|
c862b5 |
@@ -0,0 +1,11 @@
|
|
|
c862b5 |
+# profiles = xccdf_org.ssgproject.content_profile_cis
|
|
|
c862b5 |
+# platform = Red Hat Enterprise Linux 8
|
|
|
c862b5 |
+
|
|
|
c862b5 |
+#!/bin/bash
|
|
|
c862b5 |
+SSHD_CONFIG="/etc/ssh/sshd_config"
|
|
|
c862b5 |
+
|
|
|
c862b5 |
+if grep -q "^MaxSessions" $SSHD_CONFIG; then
|
|
|
c862b5 |
+ sed -i "s/^MaxSessions.*/MaxSessions 4/" $SSHD_CONFIG
|
|
|
c862b5 |
+ else
|
|
|
c862b5 |
+ echo "MaxSessions 4" >> $SSHD_CONFIG
|
|
|
c862b5 |
+fi
|
|
|
c862b5 |
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/wrong_value.fail.sh b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/wrong_value.fail.sh
|
|
|
c862b5 |
new file mode 100644
|
|
|
c862b5 |
index 0000000000..b36125f5bb
|
|
|
c862b5 |
--- /dev/null
|
|
|
c862b5 |
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/wrong_value.fail.sh
|
|
|
c862b5 |
@@ -0,0 +1,11 @@
|
|
|
c862b5 |
+# profiles = xccdf_org.ssgproject.content_profile_cis
|
|
|
c862b5 |
+# platform = Red Hat Enterprise Linux 8
|
|
|
c862b5 |
+
|
|
|
c862b5 |
+#!/bin/bash
|
|
|
c862b5 |
+SSHD_CONFIG="/etc/ssh/sshd_config"
|
|
|
c862b5 |
+
|
|
|
c862b5 |
+if grep -q "^MaxSessions" $SSHD_CONFIG; then
|
|
|
c862b5 |
+ sed -i "s/^MaxSessions.*/MaxSessions 10/" $SSHD_CONFIG
|
|
|
c862b5 |
+ else
|
|
|
c862b5 |
+ echo "MaxSessions 10" >> $SSHD_CONFIG
|
|
|
c862b5 |
+fi
|
|
|
c862b5 |
|
|
|
c862b5 |
From 027299726c805b451b02694c737514750fd14b94 Mon Sep 17 00:00:00 2001
|
|
|
c862b5 |
From: Watson Sato <wsato@redhat.com>
|
|
|
c862b5 |
Date: Wed, 13 May 2020 20:53:50 +0200
|
|
|
c862b5 |
Subject: [PATCH 2/2] Add remediations for sshd_set_max_sessions
|
|
|
c862b5 |
|
|
|
c862b5 |
---
|
|
|
c862b5 |
.../sshd_set_max_sessions/ansible/shared.yml | 8 ++++++++
|
|
|
c862b5 |
.../ssh_server/sshd_set_max_sessions/bash/shared.sh | 12 ++++++++++++
|
|
|
c862b5 |
.../tests/correct_value.pass.sh | 2 +-
|
|
|
c862b5 |
.../sshd_set_max_sessions/tests/wrong_value.fail.sh | 2 +-
|
|
|
c862b5 |
4 files changed, 22 insertions(+), 2 deletions(-)
|
|
|
c862b5 |
create mode 100644 linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/ansible/shared.yml
|
|
|
c862b5 |
create mode 100644 linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/bash/shared.sh
|
|
|
c862b5 |
|
|
|
c862b5 |
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/ansible/shared.yml b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/ansible/shared.yml
|
|
|
c862b5 |
new file mode 100644
|
|
|
c862b5 |
index 0000000000..a7e171dfe9
|
|
|
c862b5 |
--- /dev/null
|
|
|
c862b5 |
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/ansible/shared.yml
|
|
|
c862b5 |
@@ -0,0 +1,8 @@
|
|
|
c862b5 |
+# platform = multi_platform_all
|
|
|
c862b5 |
+# reboot = false
|
|
|
c862b5 |
+# strategy = configure
|
|
|
c862b5 |
+# complexity = low
|
|
|
c862b5 |
+# disruption = low
|
|
|
c862b5 |
+- (xccdf-var var_sshd_max_sessions)
|
|
|
c862b5 |
+
|
|
|
c862b5 |
+{{{ ansible_sshd_set(parameter="MaxSessions", value="{{ var_sshd_max_sessions}}") }}}
|
|
|
c862b5 |
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/bash/shared.sh b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/bash/shared.sh
|
|
|
c862b5 |
new file mode 100644
|
|
|
c862b5 |
index 0000000000..fc0a1d8b42
|
|
|
c862b5 |
--- /dev/null
|
|
|
c862b5 |
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/bash/shared.sh
|
|
|
c862b5 |
@@ -0,0 +1,12 @@
|
|
|
c862b5 |
+# platform = multi_platform_all
|
|
|
c862b5 |
+# reboot = false
|
|
|
c862b5 |
+# strategy = configure
|
|
|
c862b5 |
+# complexity = low
|
|
|
c862b5 |
+# disruption = low
|
|
|
c862b5 |
+
|
|
|
c862b5 |
+# Include source function library.
|
|
|
c862b5 |
+. /usr/share/scap-security-guide/remediation_functions
|
|
|
c862b5 |
+
|
|
|
c862b5 |
+populate var_sshd_max_sessions
|
|
|
c862b5 |
+
|
|
|
c862b5 |
+{{{ bash_sshd_config_set(parameter="MaxSessions", value="$var_sshd_max_sessions") }}}
|
|
|
c862b5 |
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/correct_value.pass.sh b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/correct_value.pass.sh
|
|
|
c862b5 |
index a816eea390..4cc6d65988 100644
|
|
|
c862b5 |
--- a/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/correct_value.pass.sh
|
|
|
c862b5 |
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/correct_value.pass.sh
|
|
|
c862b5 |
@@ -7,5 +7,5 @@ SSHD_CONFIG="/etc/ssh/sshd_config"
|
|
|
c862b5 |
if grep -q "^MaxSessions" $SSHD_CONFIG; then
|
|
|
c862b5 |
sed -i "s/^MaxSessions.*/MaxSessions 4/" $SSHD_CONFIG
|
|
|
c862b5 |
else
|
|
|
c862b5 |
- echo "MaxSessions 4" >> $SSHD_CONFIG
|
|
|
c862b5 |
+ echo "MaxSessions 4" >> $SSHD_CONFIG
|
|
|
c862b5 |
fi
|
|
|
c862b5 |
diff --git a/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/wrong_value.fail.sh b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/wrong_value.fail.sh
|
|
|
c862b5 |
index b36125f5bb..bc0c47842a 100644
|
|
|
c862b5 |
--- a/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/wrong_value.fail.sh
|
|
|
c862b5 |
+++ b/linux_os/guide/services/ssh/ssh_server/sshd_set_max_sessions/tests/wrong_value.fail.sh
|
|
|
c862b5 |
@@ -7,5 +7,5 @@ SSHD_CONFIG="/etc/ssh/sshd_config"
|
|
|
c862b5 |
if grep -q "^MaxSessions" $SSHD_CONFIG; then
|
|
|
c862b5 |
sed -i "s/^MaxSessions.*/MaxSessions 10/" $SSHD_CONFIG
|
|
|
c862b5 |
else
|
|
|
c862b5 |
- echo "MaxSessions 10" >> $SSHD_CONFIG
|
|
|
c862b5 |
+ echo "MaxSessions 10" >> $SSHD_CONFIG
|
|
|
c862b5 |
fi
|