updated solutions for practice scenerios
This commit is contained in:
@@ -63,4 +63,138 @@ curl localhost
|
|||||||
- Log Analysis
|
- Log Analysis
|
||||||
- Security Configuration
|
- Security Configuration
|
||||||
|
|
||||||
[Additional scenarios will be documented here as completed]
|
[Additional scenarios will be documented here as completed]
|
||||||
|
|
||||||
|
---
|
||||||
|
---
|
||||||
|
|
||||||
|
## Scenario: Time Synchronization and Security Configuration
|
||||||
|
|
||||||
|
### Original Problem
|
||||||
|
- Configure chronyd to sync with time server 'time.example.com'
|
||||||
|
- Configure firewall to allow HTTP (port 80) and HTTPS (port 443)
|
||||||
|
- Create an SELinux policy to allow Apache to listen on port 8080
|
||||||
|
- Configure SSH to disable root login and only allow key-based authentication
|
||||||
|
- Set up a cron job to run system updates every Sunday at 2 AM
|
||||||
|
|
||||||
|
### Environment
|
||||||
|
- OS Version: RHEL/Rocky Linux
|
||||||
|
- Initial State:
|
||||||
|
- Required Outcome:
|
||||||
|
|
||||||
|
### Solution Steps
|
||||||
|
1. Configure chronyd to sync with time server 'time.example.com'
|
||||||
|
```bash
|
||||||
|
# Install chrony
|
||||||
|
sudo dnf install chrony
|
||||||
|
|
||||||
|
# Configure chronyd to sync with time server 'time.example.com'
|
||||||
|
sudo vi /etc/chrony.conf
|
||||||
|
|
||||||
|
# Add the following line to the file
|
||||||
|
server time.example.com iburst
|
||||||
|
|
||||||
|
# Save and exit
|
||||||
|
:wq
|
||||||
|
```
|
||||||
|
The output should show the chrony service enabled and running
|
||||||
|
|
||||||
|
# Enable and start service
|
||||||
|
sudo systemctl enable chronyd
|
||||||
|
sudo systemctl start chronyd
|
||||||
|
sudo systemctl status chronyd
|
||||||
|
```
|
||||||
|
The output should show the chrony service enabled and running
|
||||||
|
|
||||||
|
2. Configure firewall to allow HTTP (port 80) and HTTPS (port 443)
|
||||||
|
```bash
|
||||||
|
# Install firewalld
|
||||||
|
sudo dnf install firewalld
|
||||||
|
|
||||||
|
# Enable and start firewalld
|
||||||
|
sudo systemctl enable --now firewalld
|
||||||
|
|
||||||
|
# Configure firewall to allow HTTP (port 80) and HTTPS (port 443)
|
||||||
|
sudo firewall-cmd --add-service=http --permanent
|
||||||
|
sudo firewall-cmd --add-service=https --permanent
|
||||||
|
```
|
||||||
|
The output should show the firewall rules added
|
||||||
|
|
||||||
|
3. Create an SELinux policy to allow Apache to listen on port 8080
|
||||||
|
```bash
|
||||||
|
# Install policycoreutils
|
||||||
|
sudo dnf install policycoreutils
|
||||||
|
|
||||||
|
# Create an SELinux policy to allow Apache to listen on port 8080
|
||||||
|
sudo semanage port -a -t http_port_t -p tcp 8080
|
||||||
|
```
|
||||||
|
The output should show the SELinux policy created
|
||||||
|
|
||||||
|
4. Configure SSH to disable root login and only allow key-based authentication
|
||||||
|
```bash
|
||||||
|
# Configure SSH to disable root login and only allow key-based authentication
|
||||||
|
sudo vi /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
# Disable root login
|
||||||
|
PermitRootLogin no
|
||||||
|
|
||||||
|
# Allow key-based authentication
|
||||||
|
PubkeyAuthentication yes
|
||||||
|
|
||||||
|
# Save and exit
|
||||||
|
:wq
|
||||||
|
|
||||||
|
# Restart SSH service
|
||||||
|
sudo systemctl restart sshd
|
||||||
|
```
|
||||||
|
The output should show the SSH configuration updated
|
||||||
|
|
||||||
|
5. Set up a cron job to run system updates every Sunday at 2 AM
|
||||||
|
```bash
|
||||||
|
# Set up a cron job to run system updates every Sunday at 2 AM
|
||||||
|
sudo crontab -e
|
||||||
|
|
||||||
|
# Add the following line to the file
|
||||||
|
0 2 * * 0 sudo dnf update
|
||||||
|
|
||||||
|
# Save and exit
|
||||||
|
:wq
|
||||||
|
|
||||||
|
# Check status of cron service
|
||||||
|
sudo systemctl status cron
|
||||||
|
```
|
||||||
|
The output should show the cron job added
|
||||||
|
|
||||||
|
### Verification
|
||||||
|
```bash
|
||||||
|
# Check chrony status
|
||||||
|
sudo systemctl status chronyd
|
||||||
|
|
||||||
|
# Check firewall status
|
||||||
|
sudo firewall-cmd --list-all
|
||||||
|
|
||||||
|
# Check SELinux status
|
||||||
|
sudo getenforce
|
||||||
|
|
||||||
|
# Check SSH status
|
||||||
|
sudo systemctl status sshd
|
||||||
|
|
||||||
|
# Check cron status
|
||||||
|
sudo systemctl status cron
|
||||||
|
```
|
||||||
|
|
||||||
|
### Key Learnings
|
||||||
|
- Understanding of systemd
|
||||||
|
- Understanding of SELinux
|
||||||
|
- Understanding of SSH
|
||||||
|
- Understanding of cron
|
||||||
|
- Understanding of firewall
|
||||||
|
- Understanding of time synchronization
|
||||||
|
|
||||||
|
## Skills Demonstrated
|
||||||
|
- Service Management
|
||||||
|
- SELinux Management
|
||||||
|
- SSH Configuration
|
||||||
|
- Cron Job Management
|
||||||
|
- Firewall Configuration
|
||||||
|
- Time Synchronization
|
||||||
|
|||||||
Reference in New Issue
Block a user