Skip to content

Host ssh config file not used in containers, resulting in SSH Error: Too many authentication failures #1956

Description

@daggerhart

v3.0.0-rc.23 on macOS Catalina

Very simple Lando file:

name: my-d8
recipe: drupal8

Simple Drush site alias:

prod:
  host: some-remote.com
  user: remote-user
  root: /app
  uri: https://some-remote.com

And a lot of SSH keys:

❯ ls -1 ~/.ssh
key1
key1.pub
key2
key2.pub
key3
key3.pub
key4
key4.pub
key5
key5.pub
key6
key6.pub
key7
key7.pub
key8
key8.pub
key9
key9.pub
key10
key10.pub
key11
key11.pub
# ... etc

In a scenario where the prod drush alias needs key13, the lando drush @prod status command will result in the Too many authentication failures error.

Normally this error can be mitigated by specifiying which key should be used for which server in your ssh config file:

❯ cat 
Host site1.com
  IdentityFile ~/.ssh/key1

Host site2.com
  IdentityFile ~/.ssh/key2

# ... etc

The Problem

The problem is that lando doesn't make the host's config the default ssh config within containers. Instead, it creates a new ssh_config file that adds each key as the identity file for all hosts -- https://github.com/lando/lando/blob/master/plugins/lando-core/scripts/load-keys.sh#L74

Mitigation

One way to mitigate this issue in a per-service way is to add a new build step:

services:
  appserver:
    build:
      - /bin/sh -c "[ -f /user/.ssh/config ] && ln -sf /user/.ssh/config /var/www/.ssh/config"

This approach of making a symlink explicitly from /user/.ssh to /var/www/.ssh is the same approach used for the known_hosts file -- https://github.com/lando/lando/blob/master/plugins/lando-core/scripts/user-perms.sh#L64

Potential Solution

A more reliable solution would be to create the symlink during the lando build process in /plugins/lando-core/scripts/user-perms.sh so that each service has the appropriate config.

Not sure what the impact of this change would be on existing lando users, but it seems that if the host machine has defined a config file, they may want that to be their config file within lando service containers.


Possibly related to #478

Very similar to #912 which was closed when the reporter accepted the suggestion to copy to config file into place.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething aint working right!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions