mirror of
https://github.com/phusion/baseimage-docker.git
synced 2026-03-26 12:29:07 +00:00
Use tools/docker-ssh in make ssh and in test/runner.sh to connect to container via SSH, fix SSH connection by IP issue on Mac-OS
This commit is contained in:
6
Makefile
6
Makefile
@@ -28,14 +28,10 @@ release: test tag_latest
|
|||||||
@echo "*** Don't forget to create a tag by creating an official GitHub release."
|
@echo "*** Don't forget to create a tag by creating an official GitHub release."
|
||||||
|
|
||||||
ssh: SSH_COMMAND?=
|
ssh: SSH_COMMAND?=
|
||||||
ssh: SSH_IDENTITY_FILE?=image/services/sshd/keys/insecure_key
|
|
||||||
ssh:
|
ssh:
|
||||||
chmod 600 ${SSH_IDENTITY_FILE}
|
|
||||||
ID=$$(docker ps | grep -F "$(NAME):$(VERSION)" | awk '{ print $$1 }') && \
|
ID=$$(docker ps | grep -F "$(NAME):$(VERSION)" | awk '{ print $$1 }') && \
|
||||||
if test "$$ID" = ""; then echo "Container is not running."; exit 1; fi && \
|
if test "$$ID" = ""; then echo "Container is not running."; exit 1; fi && \
|
||||||
IP=$$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $$ID) && \
|
tools/docker-ssh $$ID ${SSH_COMMAND}
|
||||||
echo "SSHing into $$IP" && \
|
|
||||||
ssh -v -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${SSH_IDENTITY_FILE} root@$$IP ${SSH_COMMAND}
|
|
||||||
|
|
||||||
test_release:
|
test_release:
|
||||||
echo test_release
|
echo test_release
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ docker exec $ID sv start /etc/service/sshd
|
|||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
echo " --> Logging into container and running tests"
|
echo " --> Logging into container and running tests"
|
||||||
cp image/services/sshd/keys/insecure_key /tmp/insecure_key
|
|
||||||
sleep 1 # Give container some more time to start up.
|
sleep 1 # Give container some more time to start up.
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
NAME=$NAME VERSION=$VERSION SSH_IDENTITY_FILE=/tmp/insecure_key \
|
tools/docker-ssh $ID < test/test.sh
|
||||||
SSH_COMMAND="'/bin/bash -s' < $DIR/test.sh" make ssh
|
|
||||||
|
|||||||
@@ -58,6 +58,13 @@ fi
|
|||||||
|
|
||||||
KNOWN_HOSTS_FILE=`mktemp /tmp/docker-ssh.XXXXXXXXX`
|
KNOWN_HOSTS_FILE=`mktemp /tmp/docker-ssh.XXXXXXXXX`
|
||||||
IP=`docker inspect -f "{{ .NetworkSettings.IPAddress }}" "$CONTAINER_ID"`
|
IP=`docker inspect -f "{{ .NetworkSettings.IPAddress }}" "$CONTAINER_ID"`
|
||||||
|
PORT=`docker inspect -f '{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}}' "$CONTAINER_ID"`
|
||||||
|
if test "`uname`" = "Darwin"; then
|
||||||
|
IP="127.0.0.1"
|
||||||
|
else
|
||||||
|
PORT=22
|
||||||
|
fi
|
||||||
|
echo "SSHing into $IP:$PORT"
|
||||||
|
|
||||||
# Prevent SSH from warning about adding a host to the known_hosts file.
|
# Prevent SSH from warning about adding a host to the known_hosts file.
|
||||||
ssh-keyscan "$IP" >"$KNOWN_HOSTS_FILE" 2>&1
|
ssh-keyscan "$IP" >"$KNOWN_HOSTS_FILE" 2>&1
|
||||||
@@ -68,6 +75,7 @@ if ! ssh -i ~/.baseimage_docker_insecure_key \
|
|||||||
-o PasswordAuthentication=no \
|
-o PasswordAuthentication=no \
|
||||||
-o KbdInteractiveAuthentication=no \
|
-o KbdInteractiveAuthentication=no \
|
||||||
-o ChallengeResponseAuthentication=no \
|
-o ChallengeResponseAuthentication=no \
|
||||||
|
-p $PORT \
|
||||||
"root@$IP" "$@"
|
"root@$IP" "$@"
|
||||||
then
|
then
|
||||||
STATUS=$?
|
STATUS=$?
|
||||||
|
|||||||
Reference in New Issue
Block a user