+ Red Hat Developers is a platform for developers to access resources, tools, and information about Red Hat technologies. +
++ Visit the Red Hat Developers website to learn more. +
+diff --git a/instruqt-tracks/enhance-rhel-with-selinux/01-join-red-hat-developer-portal/assignment.md b/instruqt-tracks/enhance-rhel-with-selinux/01-join-red-hat-developer-portal/assignment.md new file mode 100644 index 00000000..557d4b9a --- /dev/null +++ b/instruqt-tracks/enhance-rhel-with-selinux/01-join-red-hat-developer-portal/assignment.md @@ -0,0 +1,17 @@ +--- +slug: join-red-hat-developer-portal +id: 4hgm3l0ym300 +type: challenge +title: Join Red Hat Developer at no cost +teaser: Join Red Hat Developer at no cost +tabs: +- title: Red Hat Login + type: browser + hostname: rhd-login +difficulty: "" +--- +Before you proceed with the next challenge, please take a moment to register for Red Hat Developer. If you already have a Red Hat account, you can use the same login credentials. + +This will help us assess user satisfaction and enable us to provide more curated content. + +Click on the `Check` button at the bottom once you have registered or logged in. diff --git a/instruqt-tracks/enhance-rhel-with-selinux/01-join-red-hat-developer-portal/check-rhd-login b/instruqt-tracks/enhance-rhel-with-selinux/01-join-red-hat-developer-portal/check-rhd-login new file mode 100644 index 00000000..53051468 --- /dev/null +++ b/instruqt-tracks/enhance-rhel-with-selinux/01-join-red-hat-developer-portal/check-rhd-login @@ -0,0 +1,41 @@ +#!/bin/bash +set -euxo pipefail +echo 'logincheck' +if [ "${LOGGEDIN-0}" = "1" ]; then + echo 'loggedin' + exit 0 +fi + +rm -f /home/user/checkResult.json +rm -f /home/user/checkAssets.json +rm -f /home/user/checkError.txt + + +echo 'dropdown check' +echo '{"location":{"conditions":[{"url":"redhat.com","condition":"contains"}]},"innerText":[{"selector":"html \u003e body","value":"Please click on Check button in the bottom right of your screen to continue with the Lab."}]}' > /home/user/checkAssets.json +until [ -f /home/user/checkResult.json ]; do + sleep 1 +done +if grep "SUCCESS" /home/user/checkResult.json; then + echo 'account dropdown' + exit 0 +fi + + +rm -f /home/user/checkResult.json +rm -f /home/user/checkAssets.json +rm -f /home/user/checkError.txt + + +echo 'email check' +echo '{"location":{"conditions":[]},"innerText":[{"selector":"html \u003e body","value":"Email address verification"}]}' > /home/user/checkAssets.json +until [ -f /home/user/checkResult.json ]; do + sleep 1 +done +cat /home/user/checkResult.json +if grep "SUCCESS" /home/user/checkResult.json; then + echo 'email validation' + exit 0 +fi +fail-message "Please login and click 'Check' button." +exit 1 \ No newline at end of file diff --git a/instruqt-tracks/enhance-rhel-with-selinux/02-selinux-modes/assignment.md b/instruqt-tracks/enhance-rhel-with-selinux/02-selinux-modes/assignment.md new file mode 100644 index 00000000..3ea7578b --- /dev/null +++ b/instruqt-tracks/enhance-rhel-with-selinux/02-selinux-modes/assignment.md @@ -0,0 +1,76 @@ +--- +slug: selinux-modes +id: 0eodsxi9otyv +type: challenge +title: SELinux modes +notes: +- type: text + contents: '## Register RHEL host using ''subscription-manager'' and verify status + of SELinux.' +tabs: +- title: Terminal + type: terminal + hostname: rhel +- title: Console + type: browser + hostname: console +difficulty: "" +--- +## Add Red Hat Subscription to host +- To view the current subscription status of host. + ``` + subscription-manager status + ``` +- Register the host using following command. +``` +subscription-manager register +``` +> [!IMPORTANT] +> If the subscription-manager registration fails, please proceed to the **console** tab, log in, and complete the form. +> Thereafter, attempt to register the host with subscription-manager again. + +- Attach the subscription to the server using the command below. +``` +subscription-manager attach +``` +## Explore SELinux modes +SELinux operates in three distinct modes: Enforcing, Permissive, and Disabled. + +- **Enforcing**: In this mode, SELinux actively enforces the defined security policies. Any violation triggers an immediate response, such as blocking unauthorized access or generating an alert. +- **Permissive**: In permissive mode, SELinux logs violations while enforcing policies and without actively blocking them. This mode is useful for identifying policy gaps before transitioning to full enforcement. +- **Disabled**: SELinux is turned off in disabled mode, and DAC becomes the primary access control mechanism. While this might be necessary for specific legacy applications, it's not recommended for systems requiring strong security. + +To check the current SELinux status +``` +sestatus +``` + +You will receive similar results on your terminal as shown below. +``` +SELinux status: enabled +SELinuxfs mount: /sys/fs/selinux +SELinux root directory: /etc/selinux +Loaded policy name: targeted +Current mode: enforcing +Mode from config file: enforcing +``` + +To make permanent changes, you have to configure the file located at /etc/selinux/config. +``` +cat /etc/selinux/config +``` +By default, SELinux in RHEL is set to **enforcing** mode, and the type is set to **targeted**, as shown below +``` +# This file controls the state of SELinux on the system. +# SELINUX= can take one of these three values: +# enforcing - SELinux security policy is enforced. +# permissive - SELinux prints warnings instead of enforcing. +# disabled - No SELinux policy is loaded. +SELINUX=enforcing +# SELINUXTYPE= can take one of these two values: +# targeted - Targeted processes are protected, +# mls - Multi Level Security protection. +SELINUXTYPE=targeted +``` + +After successful registration and exploration of SELinux modes, click on the **check** button. \ No newline at end of file diff --git a/instruqt-tracks/enhance-rhel-with-selinux/02-selinux-modes/check-rhel b/instruqt-tracks/enhance-rhel-with-selinux/02-selinux-modes/check-rhel new file mode 100644 index 00000000..09503a2e --- /dev/null +++ b/instruqt-tracks/enhance-rhel-with-selinux/02-selinux-modes/check-rhel @@ -0,0 +1,12 @@ +#!/bin/bash + +output=$(subscription-manager status) + +search_string="Unknown" + +if echo "$output" | grep -q "$search_string"; then + FAIL "Host is not registered using subscription-manager. Please redo the steps for registration." + exit -1 +else + exit 0 +fi diff --git a/instruqt-tracks/enhance-rhel-with-selinux/03-deploy-sample-app/assignment.md b/instruqt-tracks/enhance-rhel-with-selinux/03-deploy-sample-app/assignment.md new file mode 100644 index 00000000..bd56fa14 --- /dev/null +++ b/instruqt-tracks/enhance-rhel-with-selinux/03-deploy-sample-app/assignment.md @@ -0,0 +1,76 @@ +--- +slug: deploy-sample-app +id: ehrptptf6ius +type: challenge +title: Deploy sample app +notes: +- type: text + contents: '## Deploy sample Red Hat Developers website with httpd server' +tabs: +- title: Terminal + type: terminal + hostname: rhel +- title: Sample App + type: service + hostname: rhel + path: / + port: 80 +difficulty: "" +--- +Install the httpd server on the RHEL system using the following command: +``` +dnf install httpd -y +``` +Enable the httpd server and verify the status to ensure it's running. +``` +systemctl start httpd && systemctl status httpd +``` + +Press **q** to exit from status check mode on terminal + +Create a new **index.html** file in the following directory for the static website, effectively setting it up as a sample application. + +``` + cd /var/www/html/ +``` +Run the following command to create a index.html file with required content. +``` +cat << 'EOF' > index.html + + +
+ + ++ Red Hat Developers is a platform for developers to access resources, tools, and information about Red Hat technologies. +
++ Visit the Red Hat Developers website to learn more. +
++ Red Hat Developers is a platform for developers to access resources, tools, and information about Red Hat technologies. +
++ Visit the Red Hat Developers website to learn more. +
+