fix(install_2fa): additional config checks#107
Conversation
WalkthroughThe installation script for SSH two-factor authentication now includes automated validation and correction of the SSH daemon configuration file. It ensures the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant install_2fa.sh
participant sshd_config
participant SSH Service
User->>install_2fa.sh: Run script
install_2fa.sh->>sshd_config: Check for Include directive
alt Include commented out
install_2fa.sh->>sshd_config: Uncomment Include directive
else Include missing
install_2fa.sh->>sshd_config: Append Include directive
end
install_2fa.sh->>sshd_config: Check KbdInteractiveAuthentication setting
alt Setting exists but not yes
install_2fa.sh->>sshd_config: Change to yes
else Setting missing
install_2fa.sh->>sshd_config: Append setting with yes
end
install_2fa.sh->>SSH Service: Validate config and restart
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
helpers/install_2fa.sh (1)
73-82: Refine Include directive detection and addition
The current logic only matches lines that begin exactly with#IncludeorInclude, missing cases with leading whitespace or commented variants like# Include. We can consolidate the uncomment and append steps into a single, more robust sed invocation that handles whitespace and optional comment characters.Proposed diff:
- # Check if Include directive is present and not commented out - if grep -q "^#Include /etc/ssh/sshd_config.d/\*.conf" /etc/ssh/sshd_config; then - echo "❌ Include directive is commented out in /etc/ssh/sshd_config" - echo "✏️ Uncommenting Include directive..." - sudo sed -i 's|^#Include /etc/ssh/sshd_config.d/\*.conf|Include /etc/ssh/sshd_config.d/*.conf|' /etc/ssh/sshd_config - elif ! grep -q "^Include /etc/ssh/sshd_config.d/\*.conf" /etc/ssh/sshd_config; then - echo "❌ Required Include directive not found in /etc/ssh/sshd_config" - echo "✏️ Adding Include directive..." - echo "Include /etc/ssh/sshd_config.d/*.conf" | sudo tee -a /etc/ssh/sshd_config - fi + # Ensure the Include directive exists and is active + if grep -qE "^[[:space:]]*#?[[:space:]]*Include /etc/ssh/sshd_config.d/\\*\\.conf" /etc/ssh/sshd_config; then + echo "✏️ Normalizing Include directive in /etc/ssh/sshd_config" + sudo sed -ri 's|^[[:space:]]*#?[[:space:]]*Include /etc/ssh/sshd_config.d/\*\.conf|Include /etc/ssh/sshd_config.d/*.conf|' /etc/ssh/sshd_config + else + echo "✏️ Adding Include directive to /etc/ssh/sshd_config" + echo "Include /etc/ssh/sshd_config.d/*.conf" | sudo tee -a /etc/ssh/sshd_config + fi
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
|
👍 👍 |
fix(2fa): Improve SSH configuration validation and handling
Changes
Technical Details
Include /etc/ssh/sshd_config.d/*.confdirectivesedwith pipe delimiter to avoid path escaping issuesKbdInteractiveAuthenticationto ensure it's not set to "no"Testing
Security Impact
These changes ensure that all necessary SSH configuration is properly set up for 2FA to work correctly, preventing potential authentication issues while maintaining security best practices.
Summary by CodeRabbit