SSH Permission Denied when starting lima vm

Hello -
I’m new to trellis (and lima), but I can’t seem to get any site to work. It fails every time when it goes to provision with a " Failed to connect to the host via ssh: landyman@127.0.0.1: Permission denied (publickey)." message. Here is what I’m trying:

$ trellis new example.com
$ cd example.com
$ trellis init
$ trellis vm start

Here is where I get an error:

Provisioning VM...
Starting galaxy role install process
- composer (1.9.2) is already installed, skipping.
- ntp (2.5.0) is already installed, skipping.
- logrotate (v0.0.5) is already installed, skipping.
- swapfile (v2.0.38) is already installed, skipping.
- mailpit (v1.0.0) is already installed, skipping.

Running command => ansible-playbook dev.yml --inventory-file=/Users/landyman/Code/example.com/trellis/.trellis/lima/inventory -e env=development
[WARNING]: Skipping plugin
(/Users/landyman/Code/example.com/trellis/lib/trellis/plugins/vars/version.py),
cannot load: No module named 'distutils'
/Users/landyman/Code/example.com/trellis/lib/trellis/plugins/callback/vars.py:50: SyntaxWarning: invalid escape sequence '\.'
  patterns = [re.sub(r'\*', '(.)*', re.sub(r'\.', '\.', var)) for var in raw_vars if var.split('.')[0] in hostvars]
/Users/landyman/Code/example.com/trellis/lib/trellis/plugins/callback/vars.py:51: SyntaxWarning: invalid escape sequence '\.'
  keys = set(pattern.split('\.')[0] for pattern in patterns)

PLAY [WordPress Server: Install LEMP Stack with PHP and MariaDB MySQL] *********

TASK [Gathering Facts] *********************************************************
fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: landyman@127.0.0.1: Permission denied (publickey).", "unreachable": true}

PLAY RECAP *********************************************************************
default                    : ok=0    changed=0    unreachable=1    failed=0    skipped=0    rescued=0    ignored=0   

exit status 4

I’ve tried doing trellis vm sudoers | sudo tee /etc/sudoers.d/trellis with no luck. I’ve also tried adding 127.0.0.1 example.test www.example.test to /etc/hosts with no luck.
The VM seems to start OK. I can use trellis vm shell and get into the instance, but I cannot seem to ssh into it.

Any tips or things to try would be greatly appreciated. Thank you!

I finally figured this out. This was a new machine, and I never setup an SSH key on it. The error was that I couldn’t ssh into the host because the publickey was denied – because I had no public key.

A quick ssh-keygen fixed the issue.

1 Like