A
A
amf1k2018-07-24 10:24:30
SSH
amf1k, 2018-07-24 10:24:30

How to generate SSH keys for deployment on GitLab?

Generated SSH keys, added to Secret Variables and Deploy key, made a config according to the example , and it crashes with an error

Host key verification failed.

The steps I did:
1) generated on the server WHERE I will deploy, and from the user who will deploy ssh-keygen -t rsa
2) Added the public key from step 1 to the Deploy Keys of the repository with the Write access allowed checkbox
3) Added the Private key ( Private key) in the Secret variables of the repository into the SSH_PRIVATE_KEY variable
4) Config for connection testing
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)
  - ' && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
  - ssh-add <(echo "$SSH_PRIVATE_KEY")
stage_deploy:
  only:
    - dev
  script:
    - ssh [email protected]$SSH_SERVER

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
OnYourLips, 2018-07-24
@OnYourLips

I would not use the agent, but would simply explicitly specify the key. That's how it works for me.

S
SagePtr, 2018-07-24
@SagePtr

You also need to add the host to known hosts

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question