Cannot ssh to the remote server

I can successfully log on to the remote server through my local pc using ssh but cannot log on the machine when trying to copy my project through gitlab ci to the remote server. I have set up my public keys into the server and have added private key to the variable SSH_PRIVATE_KEY.My yaml file.

    image: php:latest
    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
`

And it seems like the private key is not being delivered through the ssh agent. And the error log looks like

    debug1: Next authentication method: publickey
    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