-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle-authenticator.dockerfile
More file actions
35 lines (27 loc) · 975 Bytes
/
google-authenticator.dockerfile
File metadata and controls
35 lines (27 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Use the latest AlmaLinux base image
FROM almalinux:latest
# Install necessary packages
RUN dnf install epel-release -y && \
dnf update -y && \
dnf install -y \
openssh-server \
google-authenticator \
passwd \
sudo &&\
dnf clean all &&\
ssh-keygen -A
# Create a non-root user (change "otpuser" to your preferred username)
RUN useradd -m -s /bin/bash otpuser && echo "otpuser:temporarypassword" | chpasswd
# Configure SSH
RUN mkdir -p /var/run/sshd
# Allow passwordless sudo for the test user (optional)
RUN echo 'otpuser ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/otpuser
# Enable Google Authenticator in PAM
COPY google-authenticator/etc/pam.d/sshd /etc/pam.d/sshd
# Configure SSH for OTP
COPY google-authenticator/etc/ssh/sshd_config /etc/ssh/sshd_config
COPY google-authenticator/etc/ssh/sshd_config.d/50-redhat.conf /etc/ssh/sshd_config.d/50-redhat.conf
# Expose SSH port
EXPOSE 22
# Start SSH service
CMD ["/usr/sbin/sshd", "-D"]