diff --git a/src/config.rs b/src/config.rs index c4d3f5cf..60f42b2c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -87,6 +87,7 @@ pub struct ConfigFile { git_repos: Option>, disable: Option>, remote_topgrades: Option>, + ssh_arguments: Option, } impl ConfigFile { @@ -270,6 +271,11 @@ impl Config { &self.config_file.remote_topgrades } + /// Extra SSH arguments + pub fn ssh_arguments(&self) -> &Option { + &self.config_file.ssh_arguments + } + /// Prompt for a key before exiting pub fn keep_at_end(&self) -> bool { self.opt.keep_at_end || env::var("TOPGRADE_KEEP_END").is_ok() diff --git a/src/main.rs b/src/main.rs index 6ceb4ee0..6f4d8423 100644 --- a/src/main.rs +++ b/src/main.rs @@ -132,7 +132,14 @@ fn run() -> Result<(), Error> { execute( &mut report, remote_topgrade, - || generic::run_remote_topgrade(run_type, remote_topgrade, config.run_in_tmux()), + || { + generic::run_remote_topgrade( + run_type, + remote_topgrade, + config.ssh_arguments(), + config.run_in_tmux(), + ) + }, config.no_retry(), )?; } diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 7fe7798c..b42475fa 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -137,7 +137,12 @@ pub fn run_composer_update(base_dirs: &BaseDirs, run_type: RunType) -> Result<() Ok(()) } -pub fn run_remote_topgrade(run_type: RunType, hostname: &str, run_in_tmux: bool) -> Result<(), Error> { +pub fn run_remote_topgrade( + run_type: RunType, + hostname: &str, + ssh_arguments: &Option, + run_in_tmux: bool, +) -> Result<(), Error> { let ssh = utils::require("ssh")?; if run_in_tmux && !run_type.dry() { @@ -149,15 +154,15 @@ pub fn run_remote_topgrade(run_type: RunType, hostname: &str, run_in_tmux: bool) unreachable!("Tmux execution is only implemented in Unix"); } else { - run_type - .execute(&ssh) - .args(&[ - "-t", - hostname, - "env", - &format!("TOPGRADE_PREFIX={}", hostname), - "topgrade", - ]) - .check_run() + let mut args = vec!["-t", hostname]; + + if let Some(ssh_arguments) = ssh_arguments { + args.extend(ssh_arguments.split_whitespace()); + } + + let env = format!("TOPGRADE_PREFIX={}", hostname); + args.extend(&["env", &env, "topgrade"]); + + run_type.execute(&ssh).args(&args).check_run() } }