ssh-generator: generate /etc/issue.d/ with VSOCK ssh info data

I find myself trying to log into a fresh ParticleOS VM started via
systemd-vmspawn all the time, but I don't know its CID. Let's show it on
the getty screen, to make it immediately visible.
This commit is contained in:
Lennart Poettering
2025-07-03 17:36:09 +02:00
parent 864a5e9ded
commit cfd8920243
5 changed files with 355 additions and 0 deletions
+9
View File
@@ -134,6 +134,7 @@ static int write_socket_unit(
const char *unit,
const char *listen_stream,
const char *comment,
const char *extra,
bool with_ssh_access_target_dependency) {
int r;
@@ -172,6 +173,9 @@ static int write_socket_unit(
"PollLimitBurst=50\n",
listen_stream);
if (extra)
fputs(extra, f);
r = fflush_and_check(f);
if (r < 0)
return log_error_errno(r, "Failed to write %s SSH socket unit: %m", comment);
@@ -245,6 +249,8 @@ static int add_vsock_socket(
"sshd-vsock.socket",
"vsock::22",
"AF_VSOCK",
"ExecStartPost=-/usr/lib/systemd/systemd-ssh-issue --make-vsock\n"
"ExecStopPre=-/usr/lib/systemd/systemd-ssh-issue --rm-vsock\n",
/* with_ssh_access_target_dependency= */ true);
if (r < 0)
return r;
@@ -280,6 +286,7 @@ static int add_local_unix_socket(
"sshd-unix-local.socket",
"/run/ssh-unix-local/socket",
"AF_UNIX Local",
/* extra= */ NULL,
/* with_ssh_access_target_dependency= */ false);
if (r < 0)
return r;
@@ -336,6 +343,7 @@ static int add_export_unix_socket(
"sshd-unix-export.socket",
"/run/host/unix-export/ssh",
"AF_UNIX Export",
/* extra= */ NULL,
/* with_ssh_access_target_dependency= */ true);
if (r < 0)
return r;
@@ -387,6 +395,7 @@ static int add_extra_sockets(
socket ?: "sshd-extra.socket",
*i,
*i,
/* extra= */ NULL,
/* with_ssh_access_target_dependency= */ true);
if (r < 0)
return r;