Roots Discourse

Deploy : Failed connection to remote repo


#1

I’m not able to deploy to my remote server, using my bitbucket repo.

PLAY [Ensure necessary variables are defined] **********************************

TASK [Ensure environment is defined] *******************************************
skipping: [localhost]

PLAY [Deploy WP site] **********************************************************

TASK [setup] *******************************************************************
Enter passphrase for key '/home/vagrant/.ssh/id_rsa':
ok: [46.101.201.178]

TASK [Ensure site is valid] ****************************************************
skipping: [46.101.201.178]

TASK [Ensure repo is valid] ****************************************************
skipping: [46.101.201.178]

TASK [deploy : include] ********************************************************

TASK [deploy : include] ********************************************************
included: /vagrant/roles/deploy/tasks/initialize.yml for 46.101.201.178

TASK [deploy : include] ********************************************************

TASK [deploy : Initialize] *****************************************************
ok: [46.101.201.178]

TASK [deploy : include] ********************************************************

TASK [deploy : include] ********************************************************
included: /vagrant/roles/deploy/tasks/update.yml for 46.101.201.178

TASK [deploy : include] ********************************************************

TASK [deploy : Check whether project source path is a git repo] ****************
ok: [46.101.201.178]

TASK [deploy : Get current git remote URL] *************************************
skipping: [46.101.201.178]

TASK [deploy : Update git remote URL] ******************************************
skipping: [46.101.201.178]

TASK [deploy : Clone project files] ********************************************
System info:
  Ansible 2.1.0.0; Linux
  Trellis at "Require Ansible 2.0.2 and remove deploy_helper"
---------------------------------------------------
Warning: Permanently added the RSA host key for IP address '104.192.143.1' to
the list of known hosts.
Error reading response length from authentication socket.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Warning: Permanently added the RSA host key for IP address '104.192.143.1' to
the list of known hosts.
Error reading response length from authentication socket.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

fatal: [46.101.201.178]: 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.1.0.0; Linux
  Trellis at "Require Ansible 2.0.2 and remove deploy_helper"
---------------------------------------------------
Git repo git@bitbucket.org:tobiasdalhof/netzkonditor.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: [46.101.201.178]: FAILED! => {"changed": false, "failed": true}
        to retry, use: --limit @deploy.retry

PLAY RECAP *********************************************************************
46.101.201.178             : ok=6    changed=0    unreachable=0    failed=1
localhost                  : ok=0    changed=0    unreachable=0    failed=0

I already checked the connection to bitbucket using ssh git@bitbucket.org on my VM, remote server and my local env. It says:

root@netzkonditor-ubuntu-512mb-fra1-01:~/.ssh# ssh git@bitbucket.org
Warning: Permanently added the RSA host key for IP address '104.192.143.3' to the list of known hosts.
Enter passphrase for key '/root/.ssh/id_rsa':
PTY allocation request failed on channel 0
logged in as tobiasdalhof.

You can use git or hg to connect to Bitbucket. Shell access is disabled.
Connection to bitbucket.org closed.

I’m missing something… please help me :frowning:

Btw: Using windows 10


#2

Did you follow the advice in the error msg and check the docs it links to?

Git repo git@bitbucket.org:tobiasdalhof/netzkonditor.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

You should not be seeing Enter passphrase for key '/root/.ssh/id_rsa': anywhere afaik.


#3

Okay I made a mistake. I was logged in as root instead of web user on my remote server. I generated a new ssh key with a passphrase on my remote and added it to my bitbucket account.

Now, it stucks on TASK [deploy : Clone project files] since some minutes

vagrant@netzkonditor:/vagrant$ ansible-playbook deploy.yml -e "site=netzkonditor.de env=production"

PLAY [Ensure necessary variables are defined] **********************************

TASK [Ensure environment is defined] *******************************************
skipping: [localhost]

PLAY [Deploy WP site] **********************************************************

TASK [setup] *******************************************************************
ok: [46.101.201.178]

TASK [Ensure site is valid] ****************************************************
skipping: [46.101.201.178]

TASK [Ensure repo is valid] ****************************************************
skipping: [46.101.201.178]

TASK [deploy : include] ********************************************************

TASK [deploy : include] ********************************************************
included: /vagrant/roles/deploy/tasks/initialize.yml for 46.101.201.178

TASK [deploy : include] ********************************************************

TASK [deploy : Initialize] *****************************************************
ok: [46.101.201.178]

TASK [deploy : include] ********************************************************

TASK [deploy : include] ********************************************************
included: /vagrant/roles/deploy/tasks/update.yml for 46.101.201.178

TASK [deploy : include] ********************************************************

TASK [deploy : Check whether project source path is a git repo] ****************
ok: [46.101.201.178]

TASK [deploy : Get current git remote URL] *************************************
skipping: [46.101.201.178]

TASK [deploy : Update git remote URL] ******************************************
skipping: [46.101.201.178]

TASK [deploy : Clone project files] ********************************************

just one sec… i’ll check those doc links…

Edit: OOooOOHHH!! Its working now. I forgot to setup SSH agent forwarding on my VM. Thank you @cfx :slight_smile:


#4

If it could help those who get to this post:

From within your vagrant VM:

$ ssh-add -l

If this returns Could not open a connection to your authentication agent, then do this:

$ eval `ssh-agent -s`

Then add your keys to the now started SSH forwarding agent

$ ssh-add

If you see this, then you’re all set, and you try deploying again:

Identity added: /home/vagrant/.ssh/id_rsa (/home/vagrant/.ssh/id_rsa)

Hope this helps.


#5

For me, I had to run ssh-add -K from my Mac Terminal.

In my opinion anything that is absolutely necessary to utilize Trellis / Bedrock / Sage should be included in the setup documentation rather than at the end of a sub-document where this was located.

I’ve made a note to myself to contribute this to the docs in the near future so hopefully the community will accept that.


#6

Thank you @s3w47m88. You are a lifesaver!