title: Can't get SSH connections through AWS Session Manager working
body: <p>I have an EC2 instance in a private subnet in which I want to copy files.</p>
  
  <p>Instead of a S3 bucket I want to use Secure File Copy through Session Manager as documented on <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started-enable-ssh-connections.html" rel="noreferrer">here</a> and announced on <a href="https://aws.amazon.com/about-aws/whats-new/2019/07/session-manager-launches-tunneling-support-for-ssh-and-scp/?nc1=h_ls" rel="noreferrer">here</a>.</p>
  
  <p>A running EC2 instance is attached with an instance profile containing the policy <code>AmazonEC2RoleforSSM</code>. On my local machine (macOS 10.14.5) the AWS CLI (aws-cli/1.16.195) and the Session Manager Plugin (1.1.26.0) is installed and <code>.ssh/config</code> is configured accordingly.</p>
  
  <ul>
  <li><p>I can log into the instance with Session Manager on the web AWS Console.</p></li>
  <li><p>I can log into the instance using the CLI with <code>aws ssm start-session --target i-XXX</code>.</p></li>
  <li><p>I can't log into the instance using SSH. I've tried 2 different OpenSSH client versions:</p></li>
  </ul>
  
  <p><strong>OpenSSH_7.9p1:</strong></p>
  
  <p>When I run <code>ssh ec2-user@i-XXX</code> it hangs infinitely. However I can see an <code>connected</code> session in the Session Manager. When I SIGTERM the process I  get following output and the session is terminated:</p>
  
  <pre><code>Command '['session-manager-plugin', '{"SessionId": "XXX", "TokenValue": "XXX", "StreamUrl": "wss://ssmmessages.eu-central-1.amazonaws.com/v1/data-channel/XXX?role=publish_subscribe", "ResponseMetadata": {"RetryAttempts": 0, "HTTPStatusCode": 200, "RequestId": "XXX", "HTTPHeaders": {"x-amzn-requestid": "XXX", "date": "Wed, 07 Aug 2019 08:47:23 GMT", "content-length": "579", "content-type": "application/x-amz-json-1.1"}}}', 'eu-central-1', 'StartSession', u'cc', '{"DocumentName": "AWS-StartSSHSession", "Target": "i-XXX", "Parameters": {"portNumber": ["22"]}}', u'https://ssm.eu-central-1.amazonaws.com']' returned non-zero exit status -13
  </code></pre>
  
  <p><strong>OpenSSH_8.0p1:</strong></p>
  
  <p>When I run <code>ssh ec2-user@i-XXX</code> I get the following error and need to manually terminate the session in the Session Manager:</p>
  
  <pre><code>kex_exchange_identification: banner line contains invalid characters
  </code></pre>