Can't deploy -

This is what I somehow needed today to deploy my site changes. Committing and adding all changes using git was fine, but when I wanted to deploy I got an error that the repo could perhaps not be reached or that I had to setup proper SSH forwarding. Just adding the key to the keychain seemed to make all work again.

3 Likes

Hi everyone,

I been following this thread, tested the suggestions too.

But I canā€™t still not deploy to my staging, but my colleague does it and we have tried to solve this now but we are stuck. Getting bored to ask him to deploy for me all the time.

Keep getting this error message at the end:
TASK [deploy : Clone project files] **********************************************************************************

System info:

  Ansible 2.4.0.0; Darwin

  Trellis at "Normalize `apt` tasks"

---------------------------------------------------

Failed to download remote objects and refs:  Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

fatal: [34.240.210.25]: FAILED! => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result"}

...ignoring

TASK [deploy : Failed connection to remote repo] *********************************************************************

System info:

  Ansible 2.4.0.0; Darwin

  Trellis at "Normalize `apt` tasks"

---------------------------------------------------

Git repo git@bitbucket.org:psturesson/aao.se.git cannot be accessed. Please

verify the repository exists and you have SSH forwarding set up correctly.

More info:

> https://roots.io/trellis/docs/deploys/#ssh-keys

> https://roots.io/trellis/docs/ssh-keys/#cloning-remote-repo-using-ssh-

agent-forwarding

fatal: [34.240.210.25]: FAILED! => {"changed": false, "failed": true}

	to retry, use: --limit @/Applications/MAMP/dev/aao.se/trellis/deploy.retry

PLAY RECAP ***********************************************************************************************************

34.240.210.25              : ok=7    changed=0    unreachable=0    failed=1   

localhost                  : ok=0    changed=0    unreachable=0    failed=0 

Any other suggestions?

Do you have access to the git repo?

I mean the site repo in wordpress_sites.yml:

Yes, I have push code and changes to the repository.

And tested with

ssh -T git@github.com

And I get access to it, when I test on my terminal.

@ellrod Does ssh-add -l list the private ssh key that grants access to your bitbucket repo? Please try ssh-add or ssh-add -K till it does.

If youā€™re on macOS Sierra or newer, please ensure your ssh agent isnā€™t ā€œforgettingā€ your ssh key. I havenā€™t read the discussion carefully, but perhaps add this to your ~/.ssh/config`:

Host *
  AddKeysToAgent yes
  UseKeychain yes

If your repo is with bitbucket, then you need to test ssh -T git@bitbucket.org and it is more applicable if run on your server because during deploys it is your server that will initiate the git clone. For example,

$ ssh -o ForwardAgent=yes web@34.240.210.25

$ ssh -T git@bitbucket.org

If this last test fails in any way, how about removing /home/web/.ssh/known_hosts from the server then exiting the SSH session and trying your deploy again.

4 Likes

Iā€™m the one that have setup the server in question. And I canā€™t wrap my head around the problems @ellrod is facing here. It seems heā€™s able to connect to the server and manually clone the repo, so as far as I can understand, the key is being forwarded.

Could there be some setting within Bitbucket thatā€™s causing this? @ellrod has pushed changes to the repo on Bitbucket which I have later deployed because we have this issue. So access

Me personally can deploy without any issue.

This resolved my issue. Thank you, Scott.

I canā€™t seem to get my deploy to work. Iā€™ve followed each of the steps listed in this thread and still getting error. Iā€™ve double checked that SSH Agent Forwarding is enabled locally and on the server and that the key is added to the SSH agent both locally on on GitHub account. Iā€™ve tried removing known_hosts from server and re-deploying.

Iā€™ve deployed before on this project with the same repository and now it isnā€™t working.

Weā€™ll need to see the actual errors youā€™re receiving in order to help here. Have you provisioned your server before deploying?

Figured it out!

After spinning up a new server and starting fresh it worked fine. So I started looking into differences in server settings between the two.

Turns out that i had changed the folder permissions/ownership of the folders on my server inside /srv/www/. Once I changed the permissions/ownership back to web:www-data it worked perfectly.

Hopefully this helps someone else out in the future.

Hi,

I am also experiencing this issue. I have double-checked that ssh forwarding is working, ran through the points described by @fullyint:

$ ssh -o ForwardAgent=yes web@[ server ip ]

$ ssh -T git@bitbucket.org

Removed known hosts and re-tried the deploy.

@smashcreative also mentioned he span up a new server and it worked with changing the file permissions to web.www-data. I have double-checked that these permissions are in place on my server and that is the case.

For me, my deployment based on a private repo on bitbucket:

Failed to execute git clone --no-checkout ā€˜https://xxx@bitbucket.org/xxx/xxxx-xxx.gitā€™ ā€˜web/app/plugins/xxx/ā€™ && cd ā€˜web/app/plugins/xxx/ā€™ && git remote add composer ā€˜https://xxx@bitbucket.org/xxx/xxx-xxx.gitā€™ && git fetch composer

Using verbose on the deploy command, I am using the following:

Ansible 2.5.3; Linux
Trellis 1.0.2: March 13th, 2019

Any help regarding this issue would be very much appreciated

I have been having exactly the issue on this thread ā€“ it works fine when I start a new server, but after a while the issue always comes back.

The one thing I havenā€™t tried is this permissions issue identified by @smashcreative.

Hereā€™s my output when I go to view permissions of /srv/www/mysite.com

lrwxrwxrwx 1 vagrant www-data 40 Jul 30 00:29 current -> /srv/www/mysite.com/releases/20190730002648
drwxr-xr-x 2 web www-data 4096 Sep 9 06:25 logs
drwxr-xr-x 3 vagrant www-data 4096 Jul 30 00:26 releases
drwxr-xr-x 4 vagrant www-data 4096 Jul 30 00:29 shared

Is that incorrect?

Happy to report that this was the issue on my site!

So, what I did to fix it was this:

ssh root@xxx.xx.xx.xx
cd /srv/www
sudo chown -R web:www-data mysite.com

And it now deploys fine!

Hi folks. I have the same issue and donā€™t know what to do. Here is the error message when i want to deploy to production. Staging works fine.

Git repo git@github.com:maroluke/naanu-website.git cannot be accessed. Please
verify the repository exists and you have SSH forwarding set up correctly.
More info:
> https://roots.io/trellis/docs/deploys/#ssh-keys
> https://roots.io/trellis/docs/ssh-keys/#cloning-remote-repo-using-ssh-
agent-forwarding

fatal: [167.99.140.xxx]: FAILED! => {ā€œchangedā€: false}

Try: ssh-add -K to store the key in the keychain.

Thank you. I tried this before but it was something totaly different: I had to update to composer 2.0. :sweat_smile:
Now all is fine :slight_smile:
But what definitaly helped was to run ansible playbooks in verbose mode like:
ansible-playbook deploy.yml -e "site=site.com env=production" -vvvv
Just add -vvvv as argument.
This gives you more detailed information about where the error occurred.

Note: First i had to enable logs and errors in /trellis/roles/deploy/tasks/update.ym:
ignore_errors: false
no_log: false

Hope this helps others with similar issues.
Cheers

1 Like

Iā€™m closing this topic. Itā€™s really old and just being used for any problems related to deploying.