Skip to content

Commit

Permalink
ssh: support virtme.ssh
Browse files Browse the repository at this point in the history
Provide an option to start sshd in the guest. The sshd init script will
be provided as a guest script by virtme-ng (if not present `virtme.ssh`
will be simply ignored).

Signed-off-by: Andrea Righi <[email protected]>
  • Loading branch information
arighi committed Dec 23, 2024
1 parent fe8484d commit da8d1c4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,16 @@ fn setup_user_session() {
run_user_session(consdev.as_str(), uid);
}

fn run_sshd() {
if let Ok(cmdline) = std::fs::read_to_string("/proc/cmdline") {
if cmdline.contains("virtme.ssh") {
if let Some(guest_tools_dir) = get_guest_tools_dir() {
utils::run_cmd(format!("{}/virtme-sshd-script", guest_tools_dir), &[]);
}
}
}
}

fn run_snapd() {
if let Ok(cmdline) = std::fs::read_to_string("/proc/cmdline") {
if cmdline.contains("virtme.snapd") {
Expand Down Expand Up @@ -1064,6 +1074,7 @@ fn run_misc_services() -> thread::JoinHandle<()> {
mount_virtme_initmounts();
fix_packaging_files();
override_system_files();
run_sshd();
run_snapd();
})
}
Expand Down

0 comments on commit da8d1c4

Please sign in to comment.