Implemented initial SSH support. Memory pressure too high for HTTPS and
SSH. Dirty commit.
This commit is contained in:
+38
-1
@@ -13,6 +13,9 @@
|
||||
#include "serial_service.h"
|
||||
#include "session_broker.h"
|
||||
#include "session_console.h"
|
||||
#include "ssh_console.h"
|
||||
#include "ssh_security.h"
|
||||
#include "ssh_transport.h"
|
||||
#include "status_led.h"
|
||||
#include "system_console.h"
|
||||
#include "usb_cdc_transport.h"
|
||||
@@ -32,7 +35,7 @@ static const char *TAG = "firmware";
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "ESP32-S3 Serial Swiss Army Knife HTTPS foundation phase started");
|
||||
ESP_LOGI(TAG, "ESP32-S3 Serial Swiss Army Knife SSH transport phase started");
|
||||
|
||||
if (esp_psram_is_initialized()) {
|
||||
ESP_LOGI(TAG, "PSRAM initialized: %u bytes", (unsigned int)esp_psram_get_size());
|
||||
@@ -88,6 +91,28 @@ void app_main(void)
|
||||
esp_err_to_name(web_runtime_error));
|
||||
}
|
||||
|
||||
ssh_security_load_result_t ssh_security_source = SSH_SECURITY_LOAD_STORED;
|
||||
esp_err_t ssh_security_error = random_error;
|
||||
if (ssh_security_error == ESP_OK) {
|
||||
ssh_security_error = ssh_security_init(&ssh_security_source);
|
||||
}
|
||||
if (ssh_security_error != ESP_OK) {
|
||||
ESP_LOGE(TAG,
|
||||
"SSH host key unavailable (%s); use UART0 'ssh reset --force' to replace it",
|
||||
esp_err_to_name(ssh_security_error));
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Using %s SSH host key",
|
||||
ssh_security_source == SSH_SECURITY_LOAD_STORED
|
||||
? "stored"
|
||||
: "newly generated");
|
||||
}
|
||||
|
||||
esp_err_t ssh_runtime_error = ssh_transport_init();
|
||||
if (ssh_runtime_error != ESP_OK) {
|
||||
ESP_LOGE(TAG, "SSH runtime initialization failed: %s",
|
||||
esp_err_to_name(ssh_runtime_error));
|
||||
}
|
||||
|
||||
wifi_app_config_t wifi_config;
|
||||
wifi_config_load_source_t wifi_config_source;
|
||||
esp_err_t wifi_config_error = random_error;
|
||||
@@ -143,6 +168,17 @@ void app_main(void)
|
||||
ESP_LOGI(TAG, "Authenticated HTTPS listening on TCP port 443");
|
||||
}
|
||||
}
|
||||
if (wifi_error == ESP_OK && web_security_error == ESP_OK &&
|
||||
ssh_security_error == ESP_OK && ssh_runtime_error == ESP_OK) {
|
||||
esp_err_t start_error = ssh_transport_start();
|
||||
if (start_error != ESP_OK) {
|
||||
ESP_LOGE(TAG, "SSH startup failed: %s; UART0 recovery remains available",
|
||||
esp_err_to_name(start_error));
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Authenticated SSH listening on TCP port %u",
|
||||
SSH_TRANSPORT_PORT);
|
||||
}
|
||||
}
|
||||
|
||||
ESP_LOGI(
|
||||
TAG,
|
||||
@@ -174,6 +210,7 @@ void app_main(void)
|
||||
ESP_ERROR_CHECK(usb_console_register_commands());
|
||||
ESP_ERROR_CHECK(wifi_console_register_commands());
|
||||
ESP_ERROR_CHECK(web_console_register_commands());
|
||||
ESP_ERROR_CHECK(ssh_console_register_commands());
|
||||
ESP_ERROR_CHECK(network_console_register_root_commands());
|
||||
ESP_ERROR_CHECK(system_console_register_commands());
|
||||
/* Upgrade late UART terminals safely and add nested completion. */
|
||||
|
||||
Reference in New Issue
Block a user