title: How to use .pem file inside Amazon Lambda to access EC2 instance
body: <p>I'm currently working on a project that take place inside the AWS environment. I have configure a S3 bucket in order to receive mails (mails are coming from  SES but that's not relevant).</p>
  
  <p>What I want to do is to create a Lambda function that will be able to access a EC2 instance and launch a python scripts. So far i have the code below. The problem is that when I created my ec2 instance, I didnt create any username or password to connect via SSH. I only have a .pem file (certificate file) to authenticate to the instance.</p>
  
  <p>I did some research but i couldn't find anything useful.</p>
  
  <pre><code>var SSH = require('simple-ssh');
  var ssh = new SSH({
      host: 'localhost',
      user: 'username',
      pass: 'password'
  });
  
  ssh.exec('python3.6 path/to/my/python/script.py', {
      out: function(stdout) {
          console.log(stdout);
      }
  }).start();
  </code></pre>
  
  <p>i've been thinking of severals solutions, but i'm not sure at all :</p>
  
  <ul>
  <li>find an SSH library in Javascript that handle .pem file</li>
  <li>converting .pem into a String (not secure at all, in my opinion).</li>
  <li>maybe create a new ssh user in EC2 ?</li>
  </ul>
  
  <p>Thanks you for your time.</p>