Skip to content

Commit

Permalink
Resolve ssh_key invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
phcadet committed Jan 18, 2020
1 parent 31a5635 commit 0a3a6a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ WORKDIR $WORK_PATH

RUN apk update && apk add openssh && apk add autossh

ARG PRIVATE_KEY
ENV PRIVATE_KEY ${PRIVATE_KEY:-invalid}
ARG SSH_KEY
ENV SSH_KEY ${SSH_KEY:-invalid}

ARG REMOTE_USER
ENV REMOTE_USER ${REMOTE_USER:-root}
Expand All @@ -19,11 +19,12 @@ ARG SSH_PORT
ENV SSH_PORT ${SSH_PORT:-22}

ARG PORT
ENV PORT ${PORT:-22}
ENV PORT ${PORT:-localhost:22}

ARG REMOTE_PORT
ENV REMOTE_PORT ${REMOTE_PORT:-2222}

COPY ./entrypoint.sh ./entrypoint.sh
RUN chmod +x ./entrypoint.sh

ENTRYPOINT './entrypoint.sh'
7 changes: 3 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/sh

echo "${PRIVATE_KEY}" > ./id_rsa
echo -e "${SSH_KEY}" > ./id_rsa
chmod 600 ./id_rsa

echo "Forward ssh to ${REMOTE_HOST}${REMOTE_PORT}"
echo "Forward ssh to ${REMOTE_HOST}:${REMOTE_PORT}"

/usr/bin/autossh M 0 -N -v -R '${PORT:-22}:${REMOTE_PORT:-2222}' -oServerAliveInterval=10 -oServerAliveCountMax=2 -oStrictHostKeyChecking=no -i ./id_rsa ${REMOTE_USER:-root}@${REMOTE_HOST:-localhost} -p ${SSH_PORT:-22}
/usr/bin/autossh -M 0 -N -v -R "${REMOTE_PORT:-0.0.0.0:2222}:${PORT:-localhost:22}" -oServerAliveInterval=10 -oServerAliveCountMax=2 -oStrictHostKeyChecking=no -i ./id_rsa ${REMOTE_USER:-root}@${REMOTE_HOST:-localhost} -p ${SSH_PORT:-22}

0 comments on commit 0a3a6a6

Please sign in to comment.