diff --git a/dtrfs_api/src/main.rs b/dtrfs_api/src/main.rs index cd11718..8b4ce41 100644 --- a/dtrfs_api/src/main.rs +++ b/dtrfs_api/src/main.rs @@ -132,8 +132,13 @@ struct SSHKeyForm { ssh_key: String, } -#[get("/ssh_key")] -async fn get_ssh_keys(req: HttpRequest) -> HttpResponse { +#[get("/server_ssh_pubkeys")] +async fn get_server_pubkeys() -> HttpResponse { + todo!(); +} + +#[get("/authorized_keys")] +async fn get_authorized_keys(req: HttpRequest) -> HttpResponse { if let Err(e) = verify(&req) { return HttpResponse::BadRequest().body(format!("Signature verification failed: {}", e)); }; @@ -143,8 +148,8 @@ async fn get_ssh_keys(req: HttpRequest) -> HttpResponse { } } -#[post("/ssh_key")] -async fn post_ssh_key(req: HttpRequest, form: web::Form) -> HttpResponse { +#[post("/authorized_keys")] +async fn post_authorized_keys(req: HttpRequest, form: web::Form) -> HttpResponse { if let Err(e) = verify(&req) { return HttpResponse::BadRequest().body(format!("Signature verification failed: {}", e)); }; @@ -194,8 +199,8 @@ async fn main() -> std::io::Result<()> { .service(post_install_form) .service(post_decrypt_form) .service(post_process_exit) - .service(post_ssh_key) - .service(get_ssh_keys) + .service(post_authorized_keys) + .service(get_authorized_keys) .service(get_report) .service(homepage) }) diff --git a/scripts/install_os.sh b/scripts/install_os.sh index 38d6701..3cc0cc2 100755 --- a/scripts/install_os.sh +++ b/scripts/install_os.sh @@ -58,3 +58,12 @@ echo "" > /mnt/etc/fstab hostname=$(cat /proc/cmdline | grep -oE 'detee_name=[0-9a-z\_\.\-]+' | cut -d '=' -f2) echo "=== Setting up guest hostname as $hostname" [[ -n "$hostname" ]] && echo $hostname > /mnt/etc/hostname + +echo "=== Generating SSH public keys" +[[ -f "/mnt/etc/ssh/ssh_host_rsa_key" ]] || + /mnt/usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' > /dev/null +[[ -f "/mnt/etc/ssh/ssh_host_ecdsa_key" ]] || + /mnt/usr/bin/ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' > /dev/null +[[ -f "/mnt/etc/ssh/ssh_host_ed25519_key" ]] || + /mnt/usr/bin/ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N '' > /dev/null +echo "=== Done! Download keys from /server_pubkeys"