mirror of
https://github.com/jnovack/autossh.git
synced 2021-09-26 16:11:30 +03:00
122 lines
3.4 KiB
YAML
122 lines
3.4 KiB
YAML
version: '3'
|
|
|
|
# Please see docs/TESTING.md for additional information.
|
|
|
|
services:
|
|
bootloader:
|
|
build:
|
|
context: ./test
|
|
dockerfile: Dockerfile.openssh
|
|
hostname: bootloader
|
|
command: /usr/bin/dumb-init /bin/sh -c "(
|
|
echo y | ssh-keygen -C testing -f /opt/id_rsa -N '';
|
|
cp /opt/id_rsa.pub /opt/authorized_keys;
|
|
chmod 600 /opt/authorized_keys;
|
|
sleep 300;
|
|
exit 1;
|
|
)"
|
|
volumes:
|
|
- sshkeys:/opt/
|
|
|
|
target:
|
|
build:
|
|
context: ./test
|
|
dockerfile: Dockerfile.openssh
|
|
depends_on:
|
|
- bootloader
|
|
hostname: target
|
|
command: /bin/sh -c "(
|
|
rm /root/.ssh/target.txt;
|
|
sed -i s/#PermitRootLogin.*/PermitRootLogin\ yes/ /etc/ssh/sshd_config;
|
|
echo root:root | chpasswd;
|
|
ssh-keygen -A;
|
|
touch /root/.ssh/target.txt;
|
|
/usr/sbin/sshd -D -e
|
|
)"
|
|
networks:
|
|
testnet:
|
|
ipv4_address: 203.0.113.100
|
|
volumes:
|
|
- sshkeys:/root/.ssh/
|
|
|
|
remote:
|
|
build:
|
|
context: ./test
|
|
dockerfile: Dockerfile.openssh
|
|
hostname: remote
|
|
depends_on:
|
|
- bootloader
|
|
command: /bin/sh -c "(
|
|
rm /root/.ssh/remote.txt;
|
|
sed -i s/#PermitRootLogin.*/PermitRootLogin\ yes/ /etc/ssh/sshd_config;
|
|
sed -i s/GatewayPorts\ no/GatewayPorts\ clientspecified/ /etc/ssh/sshd_config;
|
|
sed -i s/AllowTcpForwarding\ no/AllowTcpForwarding\ yes/ /etc/ssh/sshd_config;
|
|
echo root:root | chpasswd;
|
|
ssh-keygen -A;
|
|
touch /root/.ssh/remote.txt;
|
|
/usr/sbin/sshd -D -e
|
|
)"
|
|
networks:
|
|
testnet:
|
|
ipv4_address: 203.0.113.10
|
|
volumes:
|
|
- sshkeys:/root/.ssh/
|
|
|
|
|
|
local:
|
|
build: .
|
|
hostname: local
|
|
depends_on:
|
|
- bootloader
|
|
- remote
|
|
- target
|
|
environment:
|
|
- TERM=xterm
|
|
- SSH_BIND_IP=203.0.113.10
|
|
- SSH_REMOTE_USER=root
|
|
- SSH_REMOTE_HOST=203.0.113.10
|
|
- SSH_REMOTE_PORT=22
|
|
- SSH_TARGET_HOST=203.0.113.100
|
|
- SSH_TARGET_PORT=22
|
|
- SSH_TUNNEL_PORT=11111
|
|
- SSH_KEY_FILE=/opt/id_rsa
|
|
- SSH_KNOWN_HOSTS_FILE=/dev/null
|
|
- SSH_STRICT_HOST_IP_CHECK=false
|
|
networks:
|
|
testnet:
|
|
ipv4_address: 203.0.113.111
|
|
restart: always
|
|
volumes:
|
|
- sshkeys:/opt/
|
|
|
|
sut:
|
|
build:
|
|
context: ./test
|
|
dockerfile: Dockerfile.openssh
|
|
hostname: source
|
|
depends_on:
|
|
- local
|
|
command: /bin/sh -c "(
|
|
while [ ! -f /opt/id_rsa ]; do echo 'waiting for ssh-keygen...'; sleep 2; done;
|
|
while [ ! -f /opt/authorized_keys ]; do echo 'waiting for authorized_keys...'; sleep 2; done;
|
|
while [ ! -f /opt/remote.txt ]; do echo 'waiting for remote...'; sleep 2; done;
|
|
while [ ! -f /opt/target.txt ]; do echo 'waiting for target...'; sleep 2; done;
|
|
echo 'testing...'
|
|
ssh -o StrictHostKeyChecking=no -i /opt/id_rsa root@203.0.113.10 -p 11111 -C 'if [ `hostname` == "target" ]; then echo '[INFO ] success'; exit 0; else echo '[PANIC] hostname is not target'; exit 1; fi';
|
|
)"
|
|
networks:
|
|
testnet:
|
|
ipv4_address: 203.0.113.200
|
|
volumes:
|
|
- sshkeys:/opt/
|
|
|
|
networks:
|
|
testnet:
|
|
driver: bridge
|
|
ipam:
|
|
driver: default
|
|
config:
|
|
- subnet: 203.0.113.0/24
|
|
|
|
volumes:
|
|
sshkeys: {} |