To run in a given container:
export C={container name} && curl https://gist.githubusercontent.com/Fusion/a81a6b5c90e40846e2f9f5ab03d41bc0/raw/sshon | bash
[ "$C" == "" ] && { echo "Syntax: export C={containername} && curl ..."; exit 1; } | |
PORT="$(docker exec -t $C ps x | grep dropbear | grep -Po '(222[0-9]{2})')" \ | |
&& PID="$(docker exec -t $C cat /var/run/dropbear.pid | tr -cd '[:print:]')" | |
docker exec -t $C kill $PID | |
docker stop ssher-${PORT} |
[ "$C" == "" ] && { echo "Syntax: export C={containername} && curl ..."; exit 1; } | |
P1=$(netstat -plnt 2>/dev/null | grep -Po '(222[0-9]{2})' | sort | tail -1) && P2=${P1:-22199} && PORT=$((P2 + 1)) \ | |
&& IP=$((docker exec -t $C ip addr) | grep -Po '(172\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})') | |
[ $? -ne 0 ] && { exit 1; } | |
while [ "$(docker exec -t $C ps aux | grep dropbear)" == "" ]; do | |
echo "Attempting to run dropbear"; docker exec -t $C dropbear -p $PORT; sleep 1 | |
done | |
[ $? -ne 0 ] && { exit 1; } | |
docker run -d --rm --name ssher-${PORT} -p ${PORT}:${PORT} svendowideit/ambassador ${IP} ${PORT} \ | |
&& echo "To terminate this SSH environment: export C={containername} && curl https://gist.githubusercontent.com/Fusion/a81a6b5c90e40846e2f9f5ab03d41bc0/raw/sshoff | bash"; |
Or in ~/.ssh/config:
Host alias1 alias2 .. aliasn
HostName <ip or host name>
Port 22200 (or higher)
User root (or hopefully a less privileged user)
KexAlgorithms +diffie-hellman-group1-sha1
Your version of dropbear may be pretty old. Such is life with older containers. You may thus need to use your ssh client as follows: