SSH authentication

Labgrid drives boards over SSH through the exporter hosts. In CI, OIDC generates short-lived opkssh certificates to SSH to the Labgrid exporters. Those methods are managed by LabgridClient.

OPKSSH

SSH authentication with opkssh.

class hw_tests.opkssh.OPKSSH(client=None)

Set up SSH access to the hosts of a labgrid client.

Installs opkssh if missing and runs authenticate().

Parameters:

client – LabgridClient whose hosts to check. If None, the SSH check is skipped.

authenticate(client=None)

Get an SSH certificate and check access to the client hosts.

In GitHub Actions, runs opkssh login github, which writes ~/.ssh/id_ecdsa and its certificate. The job needs the id-token: write permission. Elsewhere, the user’s SSH keys are used.

check_ssh_auth(client)

Check SSH login to each host of client.

New host keys are added to known_hosts (StrictHostKeyChecking=accept-new).

Raises:

PermissionError – login to a host failed.

static ensure()

Download opkssh to ~/.local/bin if it is not in PATH.

SSHConfig

Manage the SSH config file used by tests.

class hw_tests.ssh_config.SSHConfig(path: Path = PosixPath('/home/runner/work/hw-test/hw-test/docs/_ssh_config'))

SSH config file with per-host options.

A new file includes ~/.ssh/config.

Parameters:

path – Config file. Defaults to _ssh_config in the current directory.

path: Path = PosixPath('/home/runner/work/hw-test/hw-test/docs/_ssh_config')
set_host_options(hosts, options)

Set options in the Host block for hosts.

Updates the first block that matches one of hosts, or appends a new one. Other options in the block are kept.

Parameters:
  • hosts – Host patterns for the Host line.

  • options – Maps option names to values.

configure_host(host)

Set the options to reach host.

In GitHub Actions, logs in as labgrid-client with the opkssh key and certificate. New host keys are accepted.