Add support for OpenSSH 10.6's composite ML-DSA-44 + Ed25519 host key
format (ssh-mldsa44-ed25519, per draft-ietf-sshm-composite-sigs-00),
enabled by the golang.org/x/crypto bump carrying upstream CL 848605
(golang/go#82315):
- Look up /etc/ssh/ssh_host_mldsa44_ed25519_key (matching OpenSSH's
_PATH_HOST_MLDSA44_ED25519_KEY_FILE) when running as root.
- Generate and persist $TAILSCALE_VAR/ssh/ssh_host_mldsa44_ed25519_key
in OpenSSH private key PEM format via ssh.GenerateCompositeKey and
ssh.MarshalPrivateKey when no system key is present.
- Cover ssh-mldsa44-ed25519 in host key generation, handshake,
integration, and known_hosts tests.
Updates #22864Fixes#22807
Change-Id: I18daa6fee051f46792fc6e78896d9a8f6297b742
Signed-off-by: James Tucker <james@tailscale.com>
Go 1.27 (crypto/mldsa, crypto/x509) and golang.org/x/crypto v0.59.0
already implement pure ML-DSA SSH host keys (ssh-mldsa-44, per
draft-sfluhrer-ssh-mldsa-08) and PKCS#8 private key serialization.
Filter host key specs against ssh.SupportedAlgorithms().HostKeys so
builds without ML-DSA support (such as GOFIPS140=v1.0.0) continue to
skip unsupported key types cleanly, and add mldsa44 host key
generation, system key lookup, and handshake/integration test coverage.
Updates #22864
Updates #22807
Change-Id: I191e62a9a3d439db0c999172b283d00d501e1bcc
Signed-off-by: James Tucker <james@tailscale.com>
On macOS, launchd's sshd-keygen-wrapper recreates missing system host
keys on any TCP connection to port 22. tailssh preferred system keys
and re-read them on every connection, but only advertised its keys in
Hostinfo at startup or on prefs changes, so peers then failed host key
verification. Keep using host keys tailssh previously generated even
if system keys appear later, and load the keys once per process.
Fixestailscale/corp#52474
Change-Id: I3ab9d27ecb246b91d184700ca6aabbb366f11023
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Private host keys are only ever read by tailscaled itself; writing them
0700 needlessly allows group/other to walk into the key directory.
Use 0600, and pin it in TestSSHKeyGen.
Updates tailscale/corp#50380
Signed-off-by: James Tucker <james@tailscale.com>
The main server file mixed portable session handling with Unix details:
sending SIGHUP to end a session, decoding exec.ExitError, the euid check
for whether the process can switch users, agent forwarding's chown of the
socket, and reading /etc/ssh host keys as root. Those now sit behind small
functions (hangupProcess, waitProcess, canSwitchToLocalUser,
handleSSHAgentForwarding, systemHostKeyFile, isRootUser) in the new
process_unix.go, along with the incubator's forwarded-environment pipe
helpers, and the session's *exec.Cmd moves into an embedded osSessionState
struct defined there, so that the portable code no longer refers to the
process representation at all.
user.go keeps only the portable userMeta and userLookup; the login shell
and default PATH logic moves to user_unix.go. The SFTP child entrypoint and
its stdio adapter, which incubator.go and incubator_plan9.go each had a
copy of, move to sftp.go. The c2n usernames handler gains a hook for
platforms that list users some other way than /etc/passwd.
The agent socket's uid and gid are parsed as 31-bit rather than 32-bit
unsigned values so that the conversion to int for os.Chown cannot
overflow on 32-bit platforms, which is the pattern CodeQL flags.
Updates #cleanup
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Change-Id: I4c7e2b9a0d3f5e1c8b6a4d2f0e9c7b5a3d1f8e6c
Brings in a newer version of Gliderlabs SSH with added socket forwarding support.
Fixes#12409Fixes#5295
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This makes tsnet apps not depend on x/crypto/ssh and locks that in with a test.
It also paves the wave for tsnet apps to opt-in to SSH support via a
blank feature import in the future.
Updates #12614
Change-Id: Ica85628f89c8f015413b074f5001b82b27c953a9
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>