(
self,
use_open_tunnel,
instance_id,
ssh_port,
os_user,
local_forwarding,
key_file,
ip_address,
eice_id,
eice_dns_name,
max_tunnel_duration,
parsed_globals,
)
| 372 | return proxy_command |
| 373 | |
| 374 | def _ssh( |
| 375 | self, |
| 376 | use_open_tunnel, |
| 377 | instance_id, |
| 378 | ssh_port, |
| 379 | os_user, |
| 380 | local_forwarding, |
| 381 | key_file, |
| 382 | ip_address, |
| 383 | eice_id, |
| 384 | eice_dns_name, |
| 385 | max_tunnel_duration, |
| 386 | parsed_globals, |
| 387 | ): |
| 388 | proxy_command = self._generate_open_tunnel_command( |
| 389 | instance_id, |
| 390 | ip_address, |
| 391 | ssh_port, |
| 392 | eice_id, |
| 393 | eice_dns_name, |
| 394 | max_tunnel_duration, |
| 395 | parsed_globals, |
| 396 | ) |
| 397 | |
| 398 | command = [ |
| 399 | 'ssh', |
| 400 | # adding ServerAliveInterval as default because it offers better customer experience as it let customer |
| 401 | # know about terminated connections. If we want to allow customer to override this we can add additional |
| 402 | # parameter to this cli command |
| 403 | '-o', |
| 404 | 'ServerAliveInterval=5', |
| 405 | '-p', |
| 406 | str(ssh_port), |
| 407 | '-i', |
| 408 | key_file, |
| 409 | os_user + '@' + ip_address, |
| 410 | ] |
| 411 | |
| 412 | ssh_path = shutil.which('ssh') |
| 413 | if ssh_path: |
| 414 | command[0] = ssh_path |
| 415 | logger.debug(f"Using ssh: {ssh_path}") |
| 416 | else: |
| 417 | raise ConfigurationError( |
| 418 | 'SSH not available. Please refer to the documentation ' |
| 419 | 'at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Connect-using-EC2-Instance-Connect-Endpoint.html.' |
| 420 | ) |
| 421 | |
| 422 | # Add local-forwarding option if users passed local-forwarding |
| 423 | if local_forwarding: |
| 424 | command.insert(-1, '-L') |
| 425 | command.insert(-1, local_forwarding) |
| 426 | |
| 427 | # If --debug is define lets add '-v' to ssh to generate debug level logs |
| 428 | if parsed_globals.debug: |
| 429 | command.insert(-1, '-v') |
| 430 | |
| 431 | # If we are trying to connect to instance in private subnet lets use open-tunnel command to use eice |
no test coverage detected