Getting: "Host key verification failed" when trying to SSH into deploy server

So I am new to CI and trying to build out my first CI/CD. It has been a very rough 4 days to say the least…

After a day of trying to get passed the “Enter passphrase for /dev/fd/63” error see https://gitlab.com/gitlab-org/gitlab-ce/issues/14434 I have moved my dev server to Digital Ocean and got passed that error, but now I am getting a new error.

Host key verification failed. ERROR: Job failed: exit code 1

I am trying to build, test and then deploy to a dev server. Dev server is on a Digital Ocean droplet. I have pieced together my .gitlab-ci.yml with all of the GL tutorials mostly from this one: https://docs.gitlab.com/ee/ci/examples/deployment/composer-npm-deploy.html

Here is my script so far:

image: trion/ng-cli-karma

before_script:
  - npm install -g --silent @angular/cli
  - npm install
  - apt-get update
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
  - mkdir -p ~/.ssh
  - eval $(ssh-agent -s)
  - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

cache:
  paths:
  - node_modules/

stages:
  - Setup
  - Test
  - Deploy Dev
  #- Deploy Staging
  #- Deploy Demo
  #- Deploy Prod

setup:
  stage: Setup
  script:
    - npm install

test:
  stage: Test
  script:
    - echo "===== Running tslint ====="
    - ./node_modules/.bin/ng lint
    # - echo "===== Running ng test ====="
    # - ./node_modules/.bin/ng test --watch=false

deploy_dev:
  stage: Deploy Dev
  # variables:
  #   CI_DEBUG_TRACE: "true"
  artifacts:
    paths:
    - dist/
  script:
    - echo "===== Running tslint ====="
    - ./node_modules/.bin/ng lint

    - echo "===== Running build dev ====="
    - ./node_modules/.bin/ng build -dev --progress false

    - echo "===== Deploying to Dev! ====="
    - ssh-add <(echo "$DEV_PRIVATE_KEY")

    - echo "===== Deploying to stark-dev ====="
    - ssh -p22 root@********* "mkdir /var/www/html_tmp"
    - scp -p22 -r dist/* root@*********:/var/www/html_tmp
    - ssh -p22 root@********* "mv /var/www/html /var/www/html_old && mv /var/www/html_tmp /var/www/html"
    - ssh -p22 root@********* "rm -rf /var/www/html_old"

The error comes after the first ssh command. I am getting to the point where I am running out of things to try… Any help or insight into what I need to do to get this over the hill would be awesome!

Update:
I did get this to finally kick off once I forced the strictHostKeyChecking.
- echo “===== Deploying to stark-dev =====”
- ssh -o “StrictHostKeyChecking=no” -p22 root@**** “mkdir /var/www/html_tmp”
- scp -o “StrictHostKeyChecking=no” -p22 -r dist/* root@:/var/www/html_tmp
- ssh -o “StrictHostKeyChecking=no” -p22 root@
“mv /var/www/html /var/www/html_old && mv /var/www/html_tmp /var/www/html”
- ssh -o “StrictHostKeyChecking=no” -p22 root@***** “rm -rf /var/www/html_old”

I am still looking for some help as to what I can do to update this to be alot less insecure.

1 Like

I am having the same issue right now and StrictHostKeyChecking=no is not working for me