1

I have the following script:

    variables:
        DEV_IP: '123'
        DEV_USER: 'root'
    before_script:
       - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
       - eval $(ssh-agent -s)
       - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
       - mkdir -p ~/.ssh
       - chmod 700 ~/.ssh
    stages:
      - test
      - deploy_dev
    test:
      script:
        - echo "OK"
    deploy_dev:
      script:
        - ssh $DEV_USER@$DEV_IP
        - pwd
      only:
        - dev
        - master

When you try to start it, the following error occurs

$ which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
/usr/bin/ssh-agent
$ eval $(ssh-agent -s)
Agent pid 6592
$ echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
Enter passphrase for (stdin): ERROR: Job failed: exit status 1

Tell me, please, what could be the problem? Variable SSH_PRIVATE_KEY I set according to the documentation. Already tried several options, nothing helped

Thanks for any help

A.Burdonskaya
  • 511
  • 1
  • 4
  • 27
  • Ok.... how is $SSH_PRIVATE_KEY set? Cause I din't see that it's been set in that sequence of commands. – eftshift0 Mar 17 '19 at 23:25
  • [Remove the passphrase for the SSH key](https://stackoverflow.com/a/112409/7976758). – phd Mar 17 '19 at 23:37

0 Answers0