Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed ssh password auth #445

Merged
merged 5 commits into from
Dec 17, 2024
Merged

Removed ssh password auth #445

merged 5 commits into from
Dec 17, 2024

Conversation

okankoAMZ
Copy link
Contributor

@okankoAMZ okankoAMZ commented Dec 13, 2024

Description of the issue

This PR addresses the need to disable SSH password authentication, challenge-response authentication, and keyboard-interactive authentication on EC2 instances for enhanced security.

Description of changes

This change adds a user_data script to the AWS EC2 instance resource in the Terraform configuration. The script performs the following actions:

  1. Disables password authentication for SSH
  2. Disables challenge-response authentication for SSH
  3. Disables keyboard-interactive authentication for SSH
  4. Restarts the SSH service to apply the changes

Note: ChallengeResponseAuthentication was replaced by KbdInteractiveAuthentication in newer versions of SSH.
Source: https://askubuntu.com/questions/1403846/ssh-challengeresponseauthentication-in-22-04-ubuntu

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

[root~]# cat /etc/ssh/sshd_config | grep Password
# Explicitly disable PasswordAuthentication. By presetting it, we
PasswordAuthentication no
PermitEmptyPasswords no
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication, then enable this but set PasswordAuthentication

terraform/ec2/common/linux/main.tf Outdated Show resolved Hide resolved
terraform/ec2/common/linux/main.tf Outdated Show resolved Hide resolved
Copy link

@the-mann the-mann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good overall. I wonder if we should add some logging as well so debugging is easier if something happens.

@okankoAMZ okankoAMZ marked this pull request as ready for review December 17, 2024 21:31
@okankoAMZ okankoAMZ requested a review from a team as a code owner December 17, 2024 21:31
@okankoAMZ okankoAMZ merged commit 505c3bb into main Dec 17, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants