Jetbrains space. docker-compose with -H flag to deploy on remote server

  docker, docker-compose, jetbrains-ide, ssh, ubuntu

I am trying to create ci pipeline using jetbrains space. Have problem with ssh authorization. Tottaly confused by ssh public/private keys.

There are two steps:

  1. building and pushing an image
docker {
        beforeBuildScript {
            content = """
                export BRANCH=${'$'}(echo ${'$'}JB_SPACE_GIT_BRANCH | cut -d'/' -f 3)
            """
        }
        build {
            file = "./Dockerfile"
        }
        push("my image") {
            tag = "version-0.$JB_SPACE_EXECUTION_NUMBER-$BRANCH"
        }
    }
  1. Call docker-compose up -d to deploy on remote server.

There are two servers.

  1. My virtual machine (ubuntu), where i want services are been started using docker.
  2. Remote jet brains cloud ci machine.

I wanna use ssh key, ed25519 or rsa. I made next steps on ubuntu server:

  • Have created a ci_user
  • Have called ssh-keygen
  • Have added public key to home/ci_user/.ssh/authorized_keys

On cloud jetbrains machine:

  • First of all i am root user here, not ci_user, so i am trying to create home folder for ci_user
  • Have added private key during ci step to /home/ci_user/.ssh/id_ed25519

So my second step is:

 container(displayName = "docker compose up", image = "docker/compose:latest") {
        env["DOCKER_HOST"] = Secrets("dev_server")
        env["CI_PSWRD"] = Secrets("ci_password")
        env["CI_USER"] = Secrets("ci_user")
        env["PRIVATE_SSH_KEY"] = Secrets("private_key")
        shellScript {
            content = """
                mkdir /home/ci_user/
                mkdir /home/ci_user/.ssh
                touch /home/ci_user/.ssh/id_ed25519
                chmod 700 /home/ci_user/.ssh
                chmod 600 /home/ci_user/.ssh/id_ed25519
                echo ${'$'}PRIVATE_SSH_KEY >> /home/ci_user/.ssh/id_ed25519
                export DOCKER_HOST=ssh://${'$'}[email protected]${'$'}DOCKER_HOST
                docker-compose up -d
            """
        }
    }

I have next error:

[13] Failed to execute script docker-compose
/tmp/_MEInmipco/paramiko/client.py:837: UserWarning: Unknown ssh-ed25519 host key for xxx.xxx.xxx.xxx : b'81ab950dfe8e8eac56d9df1bce6ee82b'
Traceback (most recent call last):
  File "bin/docker-compose", line 6, in <module>
  File "compose/cli/main.py", line 72, in main
  File "compose/cli/main.py", line 125, in perform_command
  File "compose/cli/command.py", line 76, in project_from_options
  File "compose/cli/command.py", line 142, in get_project
  File "compose/cli/docker_client.py", line 47, in get_client
  File "compose/cli/docker_client.py", line 174, in docker_client
  File "site-packages/docker/api/client.py", line 166, in __init__
  File "site-packages/docker/transport/sshconn.py", line 111, in __init__
  File "site-packages/docker/transport/sshconn.py", line 119, in _connect
  File "site-packages/paramiko/client.py", line 446, in connect
  File "site-packages/paramiko/client.py", line 765, in _auth
paramiko.ssh_exception.SSHException: No authentication methods available

What i am doing wrong?

Source: Docker Questions

LEAVE A COMMENT