Fix docker with ssh
This commit is contained in:
parent
a4b92895b2
commit
f46c445b8d
4 changed files with 13 additions and 11 deletions
|
@ -3,13 +3,8 @@ FROM fedora:38
|
|||
RUN dnf install openssh-server -y
|
||||
RUN ssh-keygen -A -v
|
||||
|
||||
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
|
||||
RUN sed -i 's/#PermitEmptyPasswords no/PermitEmptyPasswords no/' /etc/ssh/sshd_config
|
||||
RUN sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config
|
||||
|
||||
RUN sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config
|
||||
RUN sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
|
||||
RUN echo 'root:root' | chpasswd
|
||||
RUN useradd -m -G wheel test
|
||||
RUN echo 'test:test' | chpasswd
|
||||
|
||||
EXPOSE 22
|
||||
CMD ["/usr/sbin/sshd", "-D", "-o", "ListenAddress=0.0.0.0"]
|
|
@ -1,4 +1,7 @@
|
|||
servers:
|
||||
localhost:
|
||||
ansibleConnection: ssh
|
||||
ansibleUser: root
|
||||
hosts:
|
||||
localhost:
|
||||
ansible_connection: ssh
|
||||
ansible_user: test
|
||||
ansible_port: 1022
|
||||
ansible_become_password: test
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh
|
||||
docker build -t ansible_test:latest docker/
|
||||
docker run --rm -d --name ansible_test --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw -v $HOME/.ssh/id_rsa.pub:/root/.ssh/authorized_keys:ro -p 1022:22 --cgroupns=host ansible_test:latest
|
||||
docker run --rm -d --name ansible_test --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:rw -v $HOME/.ssh/id_rsa.pub:/home/test/.ssh/authorized_keys:ro -p 1022:22 --cgroupns=host ansible_test:latest
|
4
playbook.yml
Normal file
4
playbook.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- name: Install servers
|
||||
hosts: servers
|
||||
become: true
|
Loading…
Reference in a new issue