Generated SSH keys, added to Secret Variables and Deploy key, made the config by example , but it falls with an error

Host key verification failed. 

The steps that were done:

  1. Generated on the server where I will deploy, and from the user who will deploy ssh-keygen -t rsa
  2. Added a public key from item 1 in the Deploy Keys repository with a tick. Write access allowed
  3. Added Private key in the secret variables of the repository in the SSH_PRIVATE_KEY variable
  4. Config to test the connection

     image: php:7.0 before_script: - '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' - ssh-add <(echo "$SSH_PRIVATE_KEY") stage_deploy: only: - dev script: - ssh $SSH_SERVER_USER@$SSH_SERVER 
  • I will assume that the problem is in the 4th line in the before_script section: rather, everything in your image does not contain the /.dockerenv file and therefore the second part of the line is not executed where the key trust request is disabled. Exit - try to shorten the line to this: 'echo -e "Host * \ n \ tStrictHostKeyChecking no \ n \ n"> ~ / .ssh / config' and check the launch, then figure it out where /.dockerenv - Sergey Gamov jul
  • @ SergeyGamov replaced. Now the error is Permission denied (publickey, password), although it is very strange that it asks for a password, because I created the key without a password phrase - Vladimir Zryachikh
  • A password request occurs because the key did not fit and the next option is to select a password. Try this key on ssh not in the image (for example from your machine). MANDATORY) The key (public part) must be located on the server in the user's home directory in the file authorized_keys (~ / .ssh / authorized_keys) - Sergey Gamov
  • @ SergeyGamov found what the problem was. did not add in ~ / .ssh / authorized_keys - Vladimir Zryachikh

0