remote: Add support for additional SSH arguments in SshSocket (#33243)

Closes #29438

Release Notes:

- Fix SSH agent forwarding doesn't work when using SSH remote
development.
This commit is contained in:
Umesh Yadav 2025-08-15 21:43:18 +05:30 committed by GitHub
parent 7671f34f88
commit c39f294bcb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -400,6 +400,7 @@ impl SshSocket {
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.stderr(Stdio::piped()) .stderr(Stdio::piped())
.args(self.connection_options.additional_args())
.args(["-o", "ControlMaster=no", "-o"]) .args(["-o", "ControlMaster=no", "-o"])
.arg(format!("ControlPath={}", self.socket_path.display())) .arg(format!("ControlPath={}", self.socket_path.display()))
} }
@ -410,6 +411,7 @@ impl SshSocket {
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.stderr(Stdio::piped()) .stderr(Stdio::piped())
.args(self.connection_options.additional_args())
.envs(self.envs.clone()) .envs(self.envs.clone())
} }
@ -417,22 +419,26 @@ impl SshSocket {
// On Linux, we use the `ControlPath` option to create a socket file that ssh can use to // On Linux, we use the `ControlPath` option to create a socket file that ssh can use to
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
fn ssh_args(&self) -> SshArgs { fn ssh_args(&self) -> SshArgs {
SshArgs { let mut arguments = self.connection_options.additional_args();
arguments: vec![ arguments.extend(vec![
"-o".to_string(), "-o".to_string(),
"ControlMaster=no".to_string(), "ControlMaster=no".to_string(),
"-o".to_string(), "-o".to_string(),
format!("ControlPath={}", self.socket_path.display()), format!("ControlPath={}", self.socket_path.display()),
self.connection_options.ssh_url(), self.connection_options.ssh_url(),
], ]);
SshArgs {
arguments,
envs: None, envs: None,
} }
} }
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
fn ssh_args(&self) -> SshArgs { fn ssh_args(&self) -> SshArgs {
let mut arguments = self.connection_options.additional_args();
arguments.push(self.connection_options.ssh_url());
SshArgs { SshArgs {
arguments: vec![self.connection_options.ssh_url()], arguments,
envs: Some(self.envs.clone()), envs: Some(self.envs.clone()),
} }
} }