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