docker-deployment-action icon indicating copy to clipboard operation
docker-deployment-action copied to clipboard

Host key verification failed

Open gopurx opened this issue 4 years ago • 0 comments

Receiving error "Host key verification failed" while running docker stack deployment. Validated "ssh_public_key" and it is the string from known_hosts file for the target deployment machine. Below is the traces of error

Registering SSH keys... Agent pid 10 Identity added: /github/home/.ssh/id_rsa (/github/home/.ssh/id_rsa) Add known hosts Connecting to ***... Command: docker --log-level debug --host ssh://***:22 stack deploy --compose-file docker-compose.yml application_name time="2021-12-01T21:34:48Z" level=debug msg="commandconn: starting ssh with [-l username -p 22 -- host_name docker system dial-stdio]" time="2021-12-01T21:34:48Z" level=debug msg="commandconn (ssh):Host key verification failed.\r\n" time="2021-12-01T21:34:48Z" level=debug msg="commandconn: starting ssh with [-l username -p 22 -- host_name docker system dial-stdio]" time="2021-12-01T21:34:48Z" level=debug msg="commandconn (ssh):Host key verification failed.\r\n" time="2021-12-01T21:34:48Z" level=debug msg="commandconn: starting ssh with [-l username -p 22 -- host_name docker system dial-stdio]" time="2021-12-01T21:34:48Z" level=debug msg="commandconn (ssh):Host key verification failed.\r\n" time="2021-12-01T21:34:48Z" level=debug msg="FIXME: Got an status-code for which error does not match any expected type!!!: -1" module=api status_code=-1 error during connect: Get http://docker/v1.40/info: command [ssh -l username -p 22 -- host_name docker system dial-stdio] has exited with exit status 255, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=Host key verification failed.

After running the docker_deployment-action container manually and then reviewing file "/etc/ssh/ssh_known_hosts" observed a space between host_name and the public key that was fed, no sure if this is causing the issue. Upon reviewing the docker-entrypoint.sh below snippet of code seems is causing this space (instead of a comma).

echo "Add known hosts" printf '%s %s\n' "$SSH_HOST" "$INPUT_SSH_PUBLIC_KEY" > /etc/ssh/ssh_known_hosts

Removed "$SSH_HOST" from the above line and then feeding hostname part of ssh_public_key is working, means i can see ssh connection made.

Please review and suggest in resolving this error

gopurx avatar Dec 02 '21 00:12 gopurx