-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
30 lines (21 loc) · 995 Bytes
/
Dockerfile
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
FROM ubuntu:latest
# Install SSH
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
# Add a user and set a default password
RUN useradd -m ansible_user && echo "ansible_user:ansible" | chpasswd
# Create the .ssh directory for ansible_user
RUN mkdir -p /home/ansible_user/.ssh
# Copy the public key to the authorized_keys file
COPY id_ed25519.pub /home/ansible_user/.ssh/authorized_keys
# Set the correct permissions on the .ssh directory and authorized_keys file
RUN chmod 700 /home/ansible_user/.ssh && \
chmod 600 /home/ansible_user/.ssh/authorized_keys
# Set the owner of the .ssh directory and its contents to ansible_user
RUN chown -R ansible_user:ansible_user /home/ansible_user/.ssh
# SSH login fix to prevent Disconnected: No supported authentication methods available
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
# Expose the SSH port
EXPOSE 22
# Start the SSH service
CMD ["/usr/sbin/sshd", "-D"]