Skip to content

Commit

Permalink
chore: Add initial infrastructure for ssh tests (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab authored Oct 16, 2024
1 parent 83e6a6d commit 677e864
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .makim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,26 @@ groups:
help: Raise an system error
backend: bash
run: exit 3

docker:
help: Tasks with docker
tasks:
build:
help: Build the dockerfile for ssh tests
dir: containers
run: docker build -t ssh-test .

start:
help: Start a service from the dockerfile for ssh tests
dir: containers
hooks:
pre-run:
- task: docker.build
run: docker run -d -p 2222:22 --rm ssh-test

test:
help: Test ssh connection with the docker service
dir: containers
run: |
# it requires the password manually
ssh -o StrictHostKeyChecking=no testuser@localhost -p 2222
23 changes: 23 additions & 0 deletions containers/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Use a minimal base image
FROM alpine:latest

# Install OpenSSH
RUN apk add --no-cache openssh

# Create a user with a specific password
RUN adduser -D -s /bin/sh testuser && \
echo "testuser:testpassword" | chpasswd

# Generate SSH host keys
RUN ssh-keygen -A

# Enable SSH root login and password authentication
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config && \
echo "PermitEmptyPasswords no" >> /etc/ssh/sshd_config

# Expose SSH port
EXPOSE 22

# Start the SSH service
CMD ["/usr/sbin/sshd", "-D"]

0 comments on commit 677e864

Please sign in to comment.