Files
opentf/internal/communicator
Martin Atkins 8a9f1587d2 communicator/ssh: Error for public key instead of certificate
The "certificate" argument in a provisioner connection block is only used
when using an SSH certificate authority, but because it uses the same
authorized_keys syntax that could be used to represent a public key on
the remote server it's perhaps tempting to think that it's necessary to
specify a plain public key here when attempting traditional keypair-based
authentication.

The configuration handling logic previously assumed incorrectly that the
result of parsing that string would always be *ssh.Certificate if parsing
succeeded at all, but the upstream library doesn't have a
certificate-specific parsing function and so we're using the more general
parser for the authorized_keys format and so the result could potentially
be of one of the many supported public key types, which would previously
have caused a type assertion panic.

Now we'll handle this as a normal error. The fact that communicators still
use error values directly rather than diagnostics means that we need to be
more terse than I would've liked to have been in this message, since the
reader of the message might not be an SSH authentication expert, but the
provisioner/communicator functionality long predates our modern idea of
diagnostics so I tried for a compromise here of mentioning that it's okay
to omit the certificate argument when you aren't trying to use a CA in the
hope that this is sufficient hint for someone who isn't yet aware of the
differences between these two different authentication methods.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-10-21 16:07:38 -07:00
..
2024-02-08 09:48:59 +00:00