From nobody Sun Jun 28 18:40:29 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gpJBP6TVzz6jkSq for ; Sun, 28 Jun 2026 18:40:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gpJBP4KtYz3Xtl for ; Sun, 28 Jun 2026 18:40:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782672029; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=m86Zjs6kZ7ri/cYc2NFNQO2wTxFl8V636yb+2SYpedQ=; b=O1TxUxF0YQWUAhYc3zLheaYE2QE8ljSGHtNOFpEAZb1t1++4C3shWHHb3H8buBOttGwMz3 1zeNZolxvHojOhahiuIBiVX7seygp7YjwsrO5oZO6qlh35GXaMR/y4t3ZBGV5fMO1h4q6K QsPLLMsW88KXEA6+9GMUJSrjBHA2bLu9t1YRVlo3AC8Xth29NTB3qFifXYwSnM5I+UZ4gS 6NMFMIWXc/j1q9cfmd7QaL7D2xT4Oa8haxjbiWtWHwVB4WKabViILe6uec5PknPg0oAA2P HAr2qhmVEjDWUvFc6w+n/ireinkNodLQWrbMshtto7JKBKMWJt/5TFBAgYBWpg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782672029; a=rsa-sha256; cv=none; b=wqvnZVn3qfVvu3v8l7+/fhBvCJeA1NCpekZ1yJ6anSuGfFMU+hZKQAJ3XYenrvRxzpxzD+ WKTjqIQyixcf3U+8EZxWAnyXsjCChrVN66WoJ3Ei1VRM79PPVNh22D2jTjt4beKU6Xr447 UkGWU3XRmWg0YqmqMfBsDoKRQYPhI5m0RxkfLO1EkBXzpaxBbzpk+iF5PC3fiCg/q662PA FgnNtSlZORYGO+Gjqbao5EoheOsWXD3fboH+5C3sExBLlTwMJcCh2tXmctEM4qIxHFDu4I pPWL2ZWxyipdbEQXnfPLKyGT1PRZPUYxXIyQSL1y4U/XUanBlg8CCVY+VETtBA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782672029; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=m86Zjs6kZ7ri/cYc2NFNQO2wTxFl8V636yb+2SYpedQ=; b=HQUFejA1DCGt2UMdAEZeALjZ95iHuLovcgfxk8I1lCkyxSrNMUgpmNt/sJF2MtEj8Zb1vB PecCscQj/4BLmw9fWgBWkb4npbKBhdRVsdCRxrvCwpI7Hgc/E6El4ApeJJKCR7JHlg+FyF H6kqTX9aeO27Y1MfrecY8XK19xmfeVd3ZctHOdwMWF2yqc42SFxFUJTh74WHkLunJ0HTAz YwFhvQZSBP8Sy+qnojC5iy4bETEjhUGVAZWx98vSlkTrJbdH6ATy79UuI8eIDlVZIiJshY VjJQ6BkicNmkxcYr9Q9zA2kO6TF9GetU/uN01Q+znegU6YX5AVtS0KtWK5tC6w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gpJBP38GDz6nf for ; Sun, 28 Jun 2026 18:40:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 190d8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 28 Jun 2026 18:40:29 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: a67656ff5e78 - stable/15 - nuageinit: complete SSH support with ssh_deletekeys and disable_root List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: a67656ff5e78542afa177d953a74e2233875fe0f Auto-Submitted: auto-generated Date: Sun, 28 Jun 2026 18:40:29 +0000 Message-Id: <6a416a9d.190d8.1d0ee924@gitrepo.freebsd.org> The branch stable/15 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=a67656ff5e78542afa177d953a74e2233875fe0f commit a67656ff5e78542afa177d953a74e2233875fe0f Author: Baptiste Daroussin AuthorDate: 2026-06-04 20:17:03 +0000 Commit: Baptiste Daroussin CommitDate: 2026-06-28 18:32:25 +0000 nuageinit: complete SSH support with ssh_deletekeys and disable_root Add missing SSH cloud-config options from cloud-init spec: - ssh_deletekeys: remove existing SSH host keys on first boot so new ones are generated automatically by sshd(8). Implemented as delete_ssh_host_keys() in nuage.lua using lfs.dir() with a directory existence guard via lfs.attributes(). - disable_root: set PermitRootLogin to 'no' (or a custom value via disable_root_opts) in /etc/ssh/sshd_config. - disable_root_opts: optional string or array to override the PermitRootLogin value used when disable_root is true. Only the first array element is used. (cherry picked from commit 22c1f5d0ec215e36dd4448b9128b856b5441d21c) --- libexec/nuageinit/nuage.lua | 14 ++++++++++++++ libexec/nuageinit/nuageinit | 24 ++++++++++++++++++++++++ libexec/nuageinit/nuageinit.7 | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua index e2db27bc7e85..7cce4c9bece1 100644 --- a/libexec/nuageinit/nuage.lua +++ b/libexec/nuageinit/nuage.lua @@ -539,6 +539,19 @@ local function update_sshd_config(key, value) os.rename(sshd_config .. ".nuageinit", sshd_config) end +local function delete_ssh_host_keys(root) + local ssh_dir = root .. "/etc/ssh" + local attrs = lfs.attributes(ssh_dir) + if not attrs or attrs.mode ~= "directory" then + return + end + for entry in lfs.dir(ssh_dir) do + if entry:match("^ssh_host_.*key") or entry:match("^ssh_host_.*key%.pub") then + os.remove(ssh_dir .. "/" .. entry) + end + end +end + local function exec_change_password(user, password, type, expire) local root = os.getenv("NUAGE_FAKE_ROOTDIR") local cmd = "pw " @@ -761,6 +774,7 @@ local n = { addgroup = addgroup, addsshkey = addsshkey, update_sshd_config = update_sshd_config, + delete_ssh_host_keys = delete_ssh_host_keys, chpasswd = chpasswd, pkg_bootstrap = pkg_bootstrap, install_package = install_package, diff --git a/libexec/nuageinit/nuageinit b/libexec/nuageinit/nuageinit index fc8d9582b9c6..166c3503735a 100755 --- a/libexec/nuageinit/nuageinit +++ b/libexec/nuageinit/nuageinit @@ -502,6 +502,28 @@ local function ssh_pwauth(obj) nuage.update_sshd_config("PasswordAuthentication", value) end +local function ssh_deletekeys(obj) + if obj.ssh_deletekeys == nil then return end + if obj.ssh_deletekeys then + nuage.delete_ssh_host_keys(root) + end +end + +local function disable_root(obj) + if obj.disable_root == nil then return end + if obj.disable_root then + local value = "no" + if obj.disable_root_opts then + if type(obj.disable_root_opts) == "string" then + value = obj.disable_root_opts + elseif type(obj.disable_root_opts) == "table" then + value = obj.disable_root_opts[1] + end + end + nuage.update_sshd_config("PermitRootLogin", value) + end +end + local function runcmd(obj) if obj.runcmd == nil then return end local f = nil @@ -776,8 +798,10 @@ elseif line == "#cloud-config" then settimezone, groups, create_default_user, + ssh_deletekeys, ssh_keys, network_config, + disable_root, ssh_pwauth, runcmd, write_files_not_deferred, diff --git a/libexec/nuageinit/nuageinit.7 b/libexec/nuageinit/nuageinit.7 index 9651abba868f..08a64b11ff58 100644 --- a/libexec/nuageinit/nuageinit.7 +++ b/libexec/nuageinit/nuageinit.7 @@ -164,6 +164,12 @@ will be used as the name of the group, the .Qq Ar value is expected to be a list of members (array), specified by name. .El +.It Ic ssh_deletekeys +Boolean which determines if the existing SSH host keys in +.Pa /etc/ssh +should be removed on first boot. +New host keys will be generated automatically by +.Xr sshd 8 . .It Ic ssh_keys An object of multiple key/values, .Qq Cm keys @@ -183,6 +189,30 @@ boolean which determines the value of the .Qq Ic PasswordAuthentication configuration in .Pa /etc/ssh/sshd_config +.It Ic disable_root +Boolean which determines if root login via SSH should be disabled. +If set to +.Ar true , +sets +.Qq Ic PermitRootLogin +to +.Ar no +.Pq or the value specified in Ic disable_root_opts +in +.Pa /etc/ssh/sshd_config . +.It Ic disable_root_opts +String or array of options used to set the value of +.Qq Ic PermitRootLogin +in +.Pa /etc/ssh/sshd_config , +when +.Ic disable_root +is set to +.Ar true . +If not specified, defaults to +.Ar no . +.Pp +Only the first value is used when an array is provided. .It Ic network Network configuration parameters. .Pp @@ -410,6 +440,8 @@ package_update: true package_upgrade: true runcmd: - logger -t nuageinit "boot finished" +ssh_deletekeys: true +disable_root: true ssh_keys: ed25519_private: | -----BEGIN OPENSSH PRIVATE KEY-----