diff --git a/README.md b/README.md index bdd7c9a..dfde1d6 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,9 @@ cargo run-esp32c6 ``` (...) INFO - WIFI PSK: -INFO - Connect to the AP `ssh-stamp` as a DHCP client with IP: 192.168.4.1 +INFO - WIFI MAC: +INFO - SSH hostkey fingerprint: +INFO - Connect to the AP `` as a DHCP client with IP: 192.168.4.1 ``` 2. Connect a laptop/phone to the `ssh-stamp` AP using the printed PSK, then SSH into the device at `root@192.168.4.1`. diff --git a/src/espressif/net.rs b/src/espressif/net.rs index 5ee0f82..2b35f69 100644 --- a/src/espressif/net.rs +++ b/src/espressif/net.rs @@ -92,6 +92,8 @@ pub async fn if_up( mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] ); Efuse::set_mac_address(mac).map_err(|_| sunset::error::BadUsage.build())?; + + print_hostkey_fingerprint(&guard.hostkey); } let ssid_name = wifi_ssid(config).await; @@ -197,6 +199,21 @@ pub async fn wifi_password(config: &'static SunsetMutex) -> Stri } } +fn print_hostkey_fingerprint(hostkey: &sunset::SignKey) { + match hostkey { + sunset::SignKey::Ed25519(_) => { + let pubkey = hostkey.pubkey(); + match pubkey.fingerprint(ssh_key::HashAlg::Sha256) { + Ok(fp) => info!("SSH hostkey fingerprint: {}", fp), + Err(e) => warn!("Failed to compute fingerprint: {:?}", e), + } + } + _ => { + warn!("Unsupported key type for fingerprint"); + } + } +} + /// Manages the WiFi access point lifecycle. /// Starts the AP with the configured SSID and password from the config. /// Handles reconnection if the AP stops.