@@ -121,10 +121,6 @@ def username(self) -> str:
121121 def run (self , options : SSHCommandRunOptions , args ) -> SSHCommandRunResult :
122122 """Run SSH command with the given parameters and arguments"""
123123 # Get SSH command and default username from driver
124- ssh_command = self .call ("get_ssh_command" )
125- default_username = self .call ("get_default_username" )
126- ssh_identity = self .call ("get_ssh_identity" )
127-
128124 if options .direct :
129125 # Use direct TCP address
130126 try :
@@ -135,7 +131,7 @@ def run(self, options: SSHCommandRunOptions, args) -> SSHCommandRunResult:
135131 if not host or not port :
136132 raise ValueError (f"Invalid address format: { address } " )
137133 self .logger .debug ("Using direct TCP connection for SSH - host: %s, port: %s" , host , port )
138- return self ._run_ssh_local (host , port , ssh_command , options , default_username , ssh_identity , args )
134+ return self ._run_ssh_local (host , port , options , args )
139135 except (DriverMethodNotImplemented , ValueError ) as e :
140136 self .logger .error ("Direct address connection failed (%s), falling back to SSH port forwarding" , e )
141137 return self .run (SSHCommandRunOptions (
@@ -151,11 +147,12 @@ def run(self, options: SSHCommandRunOptions, args) -> SSHCommandRunResult:
151147 ) as addr :
152148 host , port = addr
153149 self .logger .debug ("SSH port forward established - host: %s, port: %s" , host , port )
154- return self ._run_ssh_local (host , port , ssh_command , options , default_username , ssh_identity , args )
150+ return self ._run_ssh_local (host , port , options , args )
155151
156- def _run_ssh_local (self , host , port , ssh_command , options , default_username , ssh_identity , args ):
152+ def _run_ssh_local (self , host , port , options , args ):
157153 """Run SSH command with the given host, port, and arguments"""
158154 # Create temporary identity file if needed
155+ ssh_identity = self .identity
159156 identity_file = None
160157 temp_file = None
161158 if ssh_identity :
@@ -178,7 +175,7 @@ def _run_ssh_local(self, host, port, ssh_command, options, default_username, ssh
178175
179176 try :
180177 # Build SSH command arguments
181- ssh_args = self ._build_ssh_command_args (ssh_command , port , default_username , identity_file , args )
178+ ssh_args = self ._build_ssh_command_args (port , identity_file , args )
182179
183180 # Separate SSH options from command arguments
184181 ssh_options , command_args = self ._separate_ssh_options_and_command_args (args )
@@ -197,10 +194,11 @@ def _run_ssh_local(self, host, port, ssh_command, options, default_username, ssh
197194 except Exception as e :
198195 self .logger .warning ("Failed to clean up temporary identity file %s: %s" , identity_file , str (e ))
199196
200- def _build_ssh_command_args (self , ssh_command , port , default_username , identity_file , args ):
197+ def _build_ssh_command_args (self , port , identity_file , args ):
201198 """Build initial SSH command arguments"""
202199 # Split the SSH command into individual arguments
203- ssh_args = shlex .split (ssh_command )
200+ ssh_args = shlex .split (self .command )
201+ default_username = self .username
204202
205203 # Add identity file if provided
206204 if identity_file :
0 commit comments