1

I usually do a:

ssh --oStrictHostKeyChecking=no -L 33333:remote_server user@domain.name -i /usr/lib/key.pem 

from my local computer to a remote aws server. Now I would like to connect AUTOMATICALLY from my ssh-container service in a container when the container is load. Is that possible? if so , what i'm doing wrong? how can I achieve this?

Container is loaded, if execute "ssh --oStrictHostKeyChecking=no -L 33333:remote_server user@domain.name -i /usr/lib/key.pem" from the shell it connect to my remote though

The reason why I'm trying this is because I have another service "phpmyadmin-container" which require that ssh connection to load mysql datadb through ssh tunnel.

Aside that I have another problem to solve with phpmyadmin(this if I go into ssh-container shell's I can see that I'm not connected.

Any help would be appreciated.

my yml file look like:

version: '3'

services:
  phpmyadmin-container:
    image: phpmyadmin/phpmyadmin
    environment:
       PMA_HOST: 127.0.0.1
       PMA_PORT: 33333
       PMA_USERNAME: user
       PMA_USERNAME_PASSWORD: pass
    ports:
      - '8080:80'

  ssh-container:
    image: nazarpc/webserver:ssh-v1
    restart: always
    volumes: 
      # this where I have the key.pem (could be anywhere ,am i right?)
      - /usr/lib:/usr/lib
    command: ssh --oStrictHostKeyChecking=no -L 33333:remote_server user@domain.name -i /usr/lib/key.pem 
    #I have also use it the way ["ssh", "--oStrictHostKeyChecking=no" ...]
MikZuit
  • 684
  • 5
  • 17
  • What actual problem are you encountering? Scanning the Compose file, `127.0.0.1` is unambiguously wrong, bind-mounting the host's `/usr/lib` into a container is likely to randomly break things, and you're not actually providing an ssh key for the container to use. I'm not sure what issue you're encountering though. – David Maze Aug 03 '18 at 09:38
  • @DavidMaze , the container is mounted, but the shh connection has not made, i can see anything in the logs. key.pem is in my host /usr/lib and I'm mounting it in the same place in my container in order to get that key – MikZuit Aug 03 '18 at 10:11

0 Answers0