Docker container for creating tunnels with autossh.
docker run -it -e HOST="[email protected]" -e FORWARD="your forwards goes here" valdisxp1/autossh
Remember to forward the ports
example:
docker run -it -e HOST="root@localhost" -e PORT=2222 -p8080:8080 -e FORWARD="-L:8080:localhost:80 -D5050" valdisxp1/autossh
Start the container with the command.
Wait for it to generate the SSH key.
Copy the key to ~/.ssh/authorized_keys for your target and then press enter.
Choose whether or not to trust the server key ("Are you sure you want to continue connecting (yes/no)"). Run ssh-keygen -lf <(ssh-keyscan localhost 2>/dev/null) on the server to compare. Alternetively you can blindly trust the server not a man in the middle. This can be skipped by setting -e TRUST="yes".
It does a test connection first then the tunnel is running.
known_hosts and the ssh key (id_rsa, id_rsa.pub), i.e. the only files in /root/.ssh directory. Therefore they can be placed in a single directory.Generating the ssh key:
ssh-keygen -t rsa -b 4096 -N '' -f id_rsa
known_hosts can be populated from output of ssh-keyscan -H <host> or set -e TRUST="yes".
docker run -v path-to-created-config:/root/.ssh/ -e HOST="[email protected]" -e FORWARD="your forwards goes here" valdisxp1/autossh
or
docker run -v path-to-known_hosts:/root/.ssh/known_hosts -v path-to-id_rsa:/root/.ssh/id_rsa -v path-to-id_rsa.pub:/root/.ssh/id_rsa.pub -e HOST="[email protected]" -e FORWARD="your forwards goes here" valdisxp1/autossh
HOST user@hostname of the target ssh serverPORT ssh port to connect; default is 22FORWARD ssh port forwards seperated by a space. See man ssh or online for full reference.TRUST set to yes or all to skip "Are you sure you want to continue connecting" (implictly trusting the server key).VERBOSE set to true to enable ssh verbose output.-L:local_port:remote_host:remote_port instead of -Llocal_port:remote_host:remote_port. Leading : allows external connections.FORWARD or arbitrary commands injected.Content type
Image
Digest
Size
8.6 MB
Last updated
about 9 years ago
docker pull valdisxp1/rpi-autossh