Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hello,
What I could suggest trying is to add a new line at the end of the PRIVATE_KEY variable so that it matches the required format.
If this does not work, what I could suggest is adding the -vvv debug flag for the scp command so that you could see the actual error rather than just the permission denied message. This extra output might give you more information on why the connection is failing.
Let me know how it goes! Regards, Bobby
Heya,
Ensure the private key stored in the PRIVATE_KEY environment variable in GitLab is in the correct format. It should start with:
-----BEGIN OPENSSH PRIVATE KEY-----
and end with:
-----END OPENSSH PRIVATE KEY-----
If the key isn’t in this format, update the environment variable in GitLab with the correct key.
In your GitLab CI job:
chmod 600 ~/.ssh/id_ed25519
Update the deploy stage to include the fixes:
deploy:
stage: deploy
script:
- mkdir -p ~/.ssh
- echo "$PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_ed25519
- chmod 600 ~/.ssh/id_ed25519
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_ed25519
- ssh-keyscan -H $DO_PUBLIC_IP_ADDRESS >> ~/.ssh/known_hosts
- chmod +x ./deploy.sh
- scp -o StrictHostKeyChecking=no -r ./.env ./docker-compose.prod.yml root@$DO_PUBLIC_IP_ADDRESS:/root/app
- bash ./deploy.sh