Cannot get trellis to work : getting ssh permission denied

Hi there,

I am new to trellis, but I have been using Bedrock for a while now, and I am trying to get it work on both Silicon and Intel.

I would like to use it for local development at least and maybe replacing DeployHQ.

But let’s focus on silicon, here is the error I get after installing and creating a new site with trellis-cli and doing trellis provision development

TASK [Gathering Facts] *********************************************************[ERROR]: Task failed: Failed to connect to the host via ssh: [email protected]: Permission denied (publickey).

Task failed.
<<< caused by >>>
Failed to connect to the host via ssh: [email protected]: Permission denied (publickey).
fatal: [default]: UNREACHABLE! => {“changed”: false, “msg”: “Task failed: Failed to connect to the host via ssh: [email protected]: Permission denied (publickey).”, “unreachable”: true}

Any help will be appreciated, many thanks.

Using :
trellis v1.14.0
lima v1.2.1
Sequoia 15.6.1

Regards,
Florian

Weird. It looks like your SSH key isn’t working with the VM. Have you removed any ssh keys by any chance? If not, I’d probably just delete the VM and create a new one, then import the database again.

As far as I remember, no, I haven’t.
I already tried deleting and creating a new vm with no luck.

I also checked the authorized_keys file on the vm, all the public key related to my private keys are present.

I also tried with vagrant and I get a different error :sleepy_face:

I also tried this workaround without luck on trellis provision development.
The vm actually starts (make a mistake in my first post) and is visible using limactl list.

I found the solution to my first issue :

It looks like the file located at trellis/.trellis/lima/inventory needed the ansible_ssh_private_key_file variable. Not sure if that’s normal.

Adding this variable, I can go further in the process but trellis provision development returns the following :

[ERROR]: The loop value must resolve to a ‘list’, not ‘str’.Origin: /Users/florian/Sites/colibri.ac/trellis/roles/common/tasks/main.yml:18:11
16 {{ item.site_keys | to_nice_yaml | indent(2) }}
17     when: item.site_keys | count
18     loop: “{{ site_keys_by_env_pair }}”^ column 11
Provide a list of items/templates, or a template resolving to a list.
fatal: [default]: FAILED! => {“msg”: “The loop value must resolve to a ‘list’, not ‘str’.”}

ansible --version
ansible [core 2.19.2]
python version = 3.13.7

any idea ?

1 Like

Based on this, maybe the issue is your ansible-core version? Try updating to the latest version of Trellis and see if that solves it.

Hi there,

After some time of research, I could get it working by forcing the trellis version to the last one :
trellis new --trellis-version v1.26.0 mywebsite.com

I don’t know why, brew is not installing the last version by default.

Also, when using v1.26.0, after running trellis vm start I am still not able to connect to the server using ssh.
I need to add
ansible_ssh_private_key_file=~/.lima/_config/userto trellis/.trellis/lima/inventory file.
Not sure if it’s a known issue.

1 Like

Shouldn’t be necessary, worth taking a look at https://roots.io/trellis/docs/troubleshooting/#ssh-keys

9 posts were split to a new topic: PermissionError: [Errno 13] Permission denied when trying to deploy

Funnily enough I just saw the exact same sequence of errors when trying to provision a new droplet from an existing Trellis 1.25 environment — permission denied and then loop value must resolve to a list. Updating to Trellis 1.26.1 (and running trellis init again) fixed it for me as well, so thank you for posting this!