diff --git a/client-linuxapp/src/serviceinfo.rs b/client-linuxapp/src/serviceinfo.rs index 8ac71cee8..6b07039e4 100644 --- a/client-linuxapp/src/serviceinfo.rs +++ b/client-linuxapp/src/serviceinfo.rs @@ -69,6 +69,25 @@ fn create_user(user: &str) -> Result<()> { Ok(()) } +fn set_passwordless_login(user: &str) -> Result<()> { + let user_info = passwd::Passwd::from_name(user); + if user_info.is_none() { + bail!("User {} for passwordless login missing", user); + } + log::info!("Setting passwordless login for user: {}", user); + Command::new("passwd") + .arg("-d") + .arg(user) + .spawn() + .context("Error spawning passwordless setup command")? + .wait() + .context(format!( + "Error setting up passwordless login for user {}", + user + ))?; + Ok(()) +} + fn install_ssh_key(user: &str, key: &str) -> Result<()> { let user_info = passwd::Passwd::from_name(user); if user_info.is_none() { @@ -627,6 +646,8 @@ async fn process_serviceinfo_in(si_in: &ServiceInfo, si_out: &mut ServiceInfo) - ))?; install_ssh_key(sshkey_user.as_ref().unwrap(), sshkey_key.as_ref().unwrap()) .context("Error installing SSH key")?; + set_passwordless_login(sshkey_user.as_ref().unwrap()) + .context("Error setting up passwordless login")?; } // Perform RHSM