user7289530
user7289530

Reputation:

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 Run command:

ssh   -f -N username@hostname -L [local port]:[database host]:[remote port] StrictHostKeyChecking=no

and getting this error:

"Host key verification failed" ERROR

Upvotes: 2

Views: 563

Answers (1)

BlueM
BlueM

Reputation: 3851

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:

  1. Use ssh-keyscan -t rsa server.example.com > ~/.ssh/my_known_hosts from within the container to add the remote host
  2. Or copy the relevant line from an existing my_known_hosts or simply COPY a the whole file to the container.

Either of these approaches should do it.

Upvotes: 1

Related Questions