Question: I'm receiving errors when trying to connect to my EC2 instance using SSH. How can I use the AWSSupport-TroubleshootSSH automation workflow to troubleshoot SSH connection issues?

When I log in to my Amazon Elastic Compute Cloud (Amazon EC2) instance over SSH with verbose messaging on I receive errors, such as "Permission denied" or "Connection refused." How can I use the AWSSupport-TroubleshootSSH automation document to troubleshoot SSH connection issues?Short descriptionAWSSupport-TroubleshootSSH installs the Amazon EC2Rescue tool. Then, it checks for and corrects some issues that cause remote connection errors when connecting to a Linux machine through SSH. Run the AWSSupport-TroubleshootSSH automation to automatically repair issues by subnet, S3 buckets, or IAM role.System requirements to use EC2Rescue for LinuxEC2Rescue for Linux requires an Amazon EC2 Linux instance that meets the following prerequisites:Supported operating systemsAmazon Linux 2Amazon Linux 2016.09+SLES 12+RHEL 7+Ubuntu 16.04+Software requirementsPython 2.7.9+ or 3.2+Note: To learn more about verbose messaging or troubleshooting other types of error messages, see Why can't I connect to my Amazon EC2 Linux instance using SSH?ResolutionBefore you begin:Copy the instance ID of the Amazon EC2 instance you want to troubleshoot. You need the instance ID to run the automation document.(Optional) Copy the ID of a subnet in the same Availability Zone as your unreachable Amazon EC2 instance. The EC2Rescue instance installs in this subnet. If you don’t specify a subnet, then the automation document creates a new temporary VPC in your AWS account. Verify that your AWS account has at least one available VPC. By default, you can create five VPCs in a Region. If you already created five VPCs in the Region, then the automation fails without changing your Amazon EC2 instance. For more information, see VPC and subnets.(Optional) Create and specify an AWS Identity and Access Management (IAM) role for automation. If you don't specify this role, then AWS Systems Manager Automation uses the permissions of the user who executes this document. For more information about creating roles for automation, see Use IAM to configure roles for Automation.Run the AWSSupport-TroubleshootSSH automation from the AWS Systems Manager consoleOpen the AWS Systems Manager console.In the navigation pane, choose Automation.Note: If the AWS Systems Manager home page opens first, choose the menu icon to open the navigation pane, and then choose Automation.Choose Execute automation.Enter AWSSupport-TroubleshootSSH in the search field, and then press Enter.Select AWSSupport-TroubleshootSSH in the search results.In the documents list, choose AWSSupport-TroubleshootSSH. The document owner is Amazon.In the Description section, verify that Document version is set to Default version at runtime.Choose Next.In the Execute automation document section, choose Simple execution.In the Input parameters section, specify the following parameters:For InstanceID, specify the ID of the unreachable instance. For Action, select FixAll.For AllowOffline, select True.Note: If this parameter is set to False and the instance isn't managed by Systems Manager, then the Automation fails.(Optional) For SubnetId, specify a subnet in an existing VPC in the same Availability Zone as the Amazon EC2 instance that you specified. By default, Systems Manager creates a new VPC, but you can specify a subnet in an existing VPC.(Optional) For S3BucketName, enter the name of a bucket that you have write permissions to. The troubleshooting logs are uploaded to this bucket, if provided.(Optional) For AutomationAssumeRole, specify the IAM role for this execution. If no role is specified, then AWS Systems Manager Automation uses the permissions of the user who executes this document.Choose Execute.To monitor the execution progress, choose the running Automation, and then choose the Steps tab. When the execution is finished, choose the Descriptions tab, and then choose View output to view the results. To view the output of individual steps, choose the Steps tab, and then choose View Outputs beside a step.Run the AWSSupport-TroubleshootSSH automation from the AWS Command Line Interface (AWS CLI)aws ssm start-automation-execution --document-name "AWSSupport-TroubleshootSSH" --document-version "\$DEFAULT" --parameters '{"InstanceId":["i-0a241ed9caf16f01e"],"Action":["FixAll"],"AllowOffline":["True"],"SubnetId":["SelectedInstanceSubnet"]}' --region us-east-1For more information about the AWSSupport-TroubleshootSSH Automation, see Smart RDP and SSH remediation with AWS Systems Manager Automation API actions.