SSH tunneling to remote server with docker
I am trying to write a Dockerfile to access a remote mySQL database using ssh tunneling.
Tried with the following
ssh -f -N username@hostname -L [local port]:[database host]:[remote port] StrictHostKeyChecking=no
and getting this error:
“Host key verification failed” ERROR
One Solution collect form web for “SSH tunneling to remote server with docker”
Assuming that the Docker container does not have access to any SSH data (i.e.: there is no
~/.ssh/known_hosts), you have two ways to handle this:
ssh-keyscan -t rsa server.example.com > ~/.ssh/my_known_hostsfrom within the container to add the remote host
- Or copy the relevant line from an existing
COPYa the whole file to the container.
Either of these approaches should do it.