Skip to content

Commit a925b8f

Browse files
committed
fix(cli): name the missing flags in the unverified SSH warning
The ssh-proxy warning blamed an older client, which is wrong when someone starts the proxy by hand. It now names the missing flags. Also say why a generated config entry turns connection sharing off: its host alias does not name the gateway, so a shared connection would serve the sandbox of the same name on another gateway without a host key check. Note that the gateway issues only Ed25519 host keys, and document that the fingerprint is read per connection and that unverified connections are allowed by default. Signed-off-by: Adrien Langou <alangou@nvidia.com>
1 parent bdfa840 commit a925b8f

5 files changed

Lines changed: 18 additions & 9 deletions

File tree

‎crates/openshell-cli/src/main.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4363,11 +4363,12 @@ async fn run_async() -> Result<()> {
43634363
.and_then(|pin| HostKeyCheck::for_relay(expectation, pin))
43644364
.map_err(|err| miette::miette!("{err}"))?,
43654365
),
4366-
// The `ssh` of such a client accepts any host key.
4366+
// An older client starts the proxy this way, and its `ssh`
4367+
// accepts any host key.
43674368
(None, None) => {
43684369
eprintln!(
4369-
"openshell: warning: this SSH connection was started by an OpenShell client that predates host-key verification, so the SSH host key is NOT verified.\n\
4370-
Restart that client (the openshell command or openshell term)."
4370+
"openshell: warning: ssh-proxy was started without --host-key and --known-hosts, so the SSH host key is NOT verified.\n\
4371+
If an OpenShell client that predates host-key verification started it, restart that client (the openshell command or openshell term)."
43714372
);
43724373
permit_unverified().map_err(|err| miette::miette!("{err}"))?;
43734374
None

‎crates/openshell-cli/src/ssh.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,8 @@ fn render_ssh_config(gateway: &str, name: &str, workspace: &str) -> Result<Strin
22552255
.map(|(key, value)| format!(" {key} {value}"))
22562256
.collect::<Vec<_>>()
22572257
.join("\n");
2258+
// The alias does not name the gateway. A connection the user shares would
2259+
// also serve the sandbox of the same name on another gateway, unchecked.
22582260
Ok(format!(
22592261
"Host {host_alias}\n User sandbox\n{options}\n ControlMaster no\n ControlPath none\n ControlPersist no\n LogLevel ERROR\n ServerAliveInterval 15\n ServerAliveCountMax 3\n ProxyCommand {proxy_cmd}\n"
22602262
))

‎crates/openshell-cli/tests/ssh_proxy_host_key_integration.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ async fn proxy_warns_and_relays_for_a_caller_that_predates_host_key_verification
354354
);
355355

356356
for (args, caller) in [
357-
(old_client, "started by an OpenShell client that predates"),
357+
(old_client, "started without --host-key and --known-hosts"),
358358
(
359359
old_name_mode(gateway),
360360
"SSH config entry for sandbox 'my-sb'",

‎crates/openshell-core/src/ssh_host_key.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ use crate::settings::parse_bool_like;
2929
pub const REQUIRE_HOST_KEY_ENV: &str = "OPENSHELL_SSH_REQUIRE_HOST_KEY";
3030
const FINGERPRINT_PREFIX: &str = "SHA256:";
3131
const UNVERIFIED: &str = "unverified";
32+
/// The only host key type a gateway issues. A second type needs its name
33+
/// here, in `HostKeyAlgorithms`, and its own blob check in the gate.
3234
const HOST_KEY_ALGORITHM: &str = "ssh-ed25519";
3335
const PIN_HEADER: &str =
3436
"# Managed by OpenShell. Rewritten from the gateway-published fingerprint; do not edit.\n";

‎docs/how-it-works/sandboxes/overview.mdx‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,10 @@ runtimes can return an empty fingerprint; an empty value cannot verify an
900900
SSH server's identity.
901901
902902
The CLI, the TUI, and generated SSH config entries check the sandbox's host
903-
key against this fingerprint on every SSH connection they open. When the SSH
904-
server presents a different key, they stop before authentication and report
903+
key against this fingerprint on every SSH connection they open. They read the
904+
fingerprint from the gateway for each connection, so a sandbox recreated under
905+
the same name is checked against its new key. When the SSH server presents a
906+
different key, they stop before authentication and report
905907
`SSH host key mismatch`.
906908
907909
They cannot verify a sandbox that has no published fingerprint. They connect
@@ -922,9 +924,11 @@ They keep working and print a warning on every connection. Replace each pasted
922924
entry with new `openshell sandbox ssh-config` output, or use `--editor` on
923925
`sandbox connect` again for that sandbox.
924926
925-
Set `OPENSHELL_SSH_REQUIRE_HOST_KEY=1` to refuse every unverified connection,
926-
to a sandbox with no published fingerprint or through such an entry, instead
927-
of connecting with a warning.
927+
Unverified connections go ahead by default. Set
928+
`OPENSHELL_SSH_REQUIRE_HOST_KEY=1` to refuse every unverified connection, to a
929+
sandbox with no published fingerprint or through such an entry, instead of
930+
connecting with a warning. Any value other than `0`, `false`, `no`, `n`, or
931+
`off` refuses them.
928932
929933
## Transfer Files
930934

0 commit comments

Comments
 (0)