NAME

Langertha::Holmgang::Sim::Linux::Sshd - OpenSSH server on a simulated Linux server — sshd -t/-T, Include, effect of reload/restart, login

VERSION

version 0.001

SYNOPSIS

# from the Linux simulator
my ( $out, $ok ) = Langertha::Holmgang::Sim::Linux::Sshd::sshd( $dev, [ '-t' ] );
Langertha::Holmgang::Sim::Linux::Sshd::load( $dev, 'ssh', 'reload' );   # dies on error
my $why = Langertha::Holmgang::Sim::Linux::Sshd::login_denied( $dev, $host );

DESCRIPTION

The OpenSSH server of a Debian 12 device of type linux (cai-platform docs/entwurf-evals.md §3.3.1). Active only when /etc/ssh/sshd_config is in the state; otherwise the service ssh stays an ordinary service.

files:
  /etc/ssh/sshd_config: "Include /etc/ssh/sshd_config.d/*.conf\n…"
  /etc/ssh/sshd_config.d/50-cloud.conf: "PasswordAuthentication yes\n"
  /etc/ssh/ssh_host_ed25519_key: { mode: "0600", content: "" }   # optional
services:
  ssh: { active: true, effective: { passwordauthentication: "yes", allowgroups: [ admins ] } }
ssh_login: { user: ops, from: 10.10.99.15 }   # optional: this is how the model is logged in

Reading the configuration like sshd: /etc/ssh/sshd_config, Include (glob, sorted; relative paths under /etc/ssh) in place; the first value of a keyword applies, lists (AllowUsers, AllowGroups, DenyUsers, DenyGroups, ListenAddress, Port, HostKey, AcceptEnv) accumulate. Lines after Match apply only conditionally and do not enter the global configuration (up to the end of the file). Unknown keywords, missing and invalid values are errors as with sshd.

Effective configuration (services.ssh.effective): the explicitly set global values (keys in lower case, lists as lists). It changes only when sshd reads the files: start, restart, reload. If the configuration is broken or no host key can be loaded (private key readable by group/others), reload fails and sshd keeps running with the old one; start/restart leave the service failed (the journal names the cause).

Commands: sshd -t, sshd -T (effective configuration of the files, with defaults), sshd -f file.

Login (ssh_login): if the service is not active, the server refuses the connection; if the running configuration excludes the user (DenyUsers, AllowUsers, DenyGroups, AllowGroups, PermitRootLogin no for root, PubkeyAuthentication no) or the account is expired or has no shell, access is lost — as on a real server where one locks oneself out.

active

True when the device has an /etc/ssh/sshd_config (only then does this module simulate sshd).

parse

my ( $settings, $errors ) = parse( $dev [, $file] );

Reads the configuration like sshd. $settings: global, explicitly set values (first wins, lists accumulated); $errors: error messages like sshd.

sshd

my ( $out, $ok ) = sshd( $dev, \@argv );

sshd -t (check: silent on success), sshd -T (effective configuration), -f file. Without -t/-T sshd refuses (already running as a service).

load

load( $dev, $service, $verb [, $host] );   # start | restart | reload

Effect on the service: reads the configuration into effective; on errors die with the message of systemctl — reload leaves the running sshd with the old configuration, start/restart leave it failed.

ssh_keygen

my ( $out, $ok ) = ssh_keygen( $dev, \@argv, $host );

ssh-keygen -A (generate missing host keys under /etc/ssh, private 0600, public 0644) and ssh-keygen -l -f file (fingerprint). Anything else is a simulation gap (undef).

login_denied

my $msg = login_denied( $dev, $host );   # undef = login works

Can ssh_login (user, origin) log in with the running configuration? Otherwise the client's message.

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/langertha-holmgang/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.