mirror of
https://github.com/dawidd6/action-ansible-playbook.git
synced 2024-12-23 12:46:15 +00:00
add testing Dockerfile and entrypoint script
This commit is contained in:
parent
e3ab322c67
commit
248919721c
2 changed files with 30 additions and 0 deletions
18
Dockerfile.test
Normal file
18
Dockerfile.test
Normal file
|
@ -0,0 +1,18 @@
|
|||
FROM alpine
|
||||
|
||||
RUN apk -U add openssh-server openssh-sftp-server sudo python3
|
||||
RUN adduser -D user
|
||||
RUN passwd -u user
|
||||
RUN passwd -u root
|
||||
RUN echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
|
||||
RUN echo "PasswordAuthentication no" > /etc/ssh/sshd_config
|
||||
RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
|
||||
RUN echo "AuthorizedKeysFile /etc/ssh/authorized_keys" >> /etc/ssh/sshd_config
|
||||
RUN echo "PermitRootLogin no" >> /etc/ssh/sshd_config
|
||||
RUN echo "Subsystem sftp /usr/lib/openssh/sftp-server" >> /etc/ssh/sshd_config
|
||||
|
||||
RUN ssh-keygen -A
|
||||
|
||||
COPY test.sh /
|
||||
|
||||
ENTRYPOINT ["/test.sh"]
|
12
test.sh
Executable file
12
test.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
key="$SSH_PUBLIC_KEY"
|
||||
|
||||
if test -z "$key"; then
|
||||
echo "set SSH_PUBLIC_KEY environment variable first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$key" > /etc/ssh/authorized_keys
|
||||
|
||||
exec /usr/sbin/sshd -D
|
Loading…
Reference in a new issue