无法通过Gitlab CI SSH到远程服务器

我正在尝试使用gitlab CICD将项目从Gitlab部署到服务器。我可以使用ssh通过本地PC成功登录到远程服务器,但是在尝试通过gitlab ci将项目复制到远程服务器时无法登录计算机。

我已经将我的公钥设置到服务器中,并将私钥添加到变量SSH_PRIVATE_KEY中。我的yaml文件。

    before_script:
        - apt-get update -qq
        - apt-get install -qq git
        - "which ssh-agent || ( apt-get install -qq openssh-client )"
        - eval $(ssh-agent -s)
        - ssh-add <(echo "$SSH_PRIVATE_KEY")
        - mkdir -p ~/.ssh
        - touch ~/.ssh/known_hosts
        - ssh-keyscan -H ip >> ~/.ssh/known_hosts
        - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

    deploy_stage:
        stage: deploy
        environment: Staging
        only:
            - master
        script:
            - ls
            - scp -vvv -o StrictHostKeyChecking=no -P 1157 -r * user@host

“错误日志是。”

    debug1: Offering public key: /dev/fd/63 RSA     SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxx agent
    debug3: send packet: type 50
    debug2: we sent a publickey packet,wait for reply
    debug3: receive packet: type 51
    debug1: Authentications that can continue: 
    debug1: Trying private key: /root/.ssh/id_rsa
    debug3: no such identity: /root/.ssh/id_rsa: No such file or directory
    debug1: Trying private key: /root/.ssh/id_dsa
    debug3: no such identity: /root/.ssh/id_dsa: No such file or directory
    debug1: Trying private key: /root/.ssh/id_ecdsa
    debug3: no such identity: /root/.ssh/id_ecdsa: No such file or directory
    debug1: Trying private key: /root/.ssh/id_ed25519
    debug3: no such identity: /root/.ssh/id_ed25519: No such file or directory
    debug1: Trying private key: /root/.ssh/id_xmss
    debug3: no such identity: /root/.ssh/id_xmss: No such file or directory
    debug2: we did not send a packet,disable method
lxg1238 回答:无法通过Gitlab CI SSH到远程服务器

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3160497.html

大家都在问