This repository has been archived by the owner on Aug 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·62 lines (51 loc) · 2.11 KB
/
test.sh
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -ev
echo "Building and running image ..."
docker build -t debian .
docker run -d -P \
-e "SMTP_HOST=testhost" \
-e "SMTP_AUTH_USER=testuser" \
-e "SMTP_AUTH_PASS=testpassword" \
-e "SMTP_STARTTLS=teststarttls" \
--name debian debian
echo "Waiting some time, because the process manager inside the container runs async to the docker run command ..."
sleep 10
echo "Checking if container is running ..."
docker ps | grep debian
echo "Checking existence of some binaries and packages ..."
docker exec debian dpkg -s ca-certificates
docker exec debian which cron
docker exec debian which curl
docker exec debian which git
docker exec debian which nano
docker exec debian which sshd
docker exec debian which ssmtp
docker exec debian which supervisord
docker exec debian which unzip
docker exec debian which vim
docker exec debian which wget
echo "Check if environment variables are present in ssmtp config file ..."
docker exec debian grep testhost /etc/ssmtp/ssmtp.conf
docker exec debian grep testuser /etc/ssmtp/ssmtp.conf
docker exec debian grep testpassword /etc/ssmtp/ssmtp.conf
docker exec debian grep UseSTARTTLS /etc/ssmtp/ssmtp.conf
echo "Check if sshd is running inside the container ..."
docker exec debian ps aux | grep sshd
echo "Connecting to SSH and run test command ..."
ssh-keygen -f ~/.ssh/test_rsa -t rsa -N ''
docker cp ~/.ssh/test_rsa.pub debian:/root/.ssh/authorized_keys
docker exec -ti debian cat /root/.ssh/authorized_keys
docker exec -ti debian chown root:root /root/.ssh/authorized_keys
export IP="127.0.0.1"
export PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}}' debian)
docker ps
ssh -v -p $PORT -i ~/.ssh/test_rsa -o "StrictHostKeyChecking no" -t root@$IP "pwd"
docker rm -f debian
#echo "Connecting to SSH with password"
#sudo apt-get -qq update
#sudo apt-get install -y sshpass
#docker run -d -P \
#-e "SSH_ROOT_PASS=testpassword" \
#--name debian debian
#export PORT=$(docker inspect --format='{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}}' debian)
#sshpass -p 'testpassword' ssh -v -p $PORT -o "StrictHostKeyChecking no" -t root@$IP "pwd"