Cannot parse privateKey : Unsupported key format AWS Lambda function in Node





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I been seeking for this problem and cannot find a proper solution for this.
This is my code base. I have pass the Private KEY under private key and """ Private Key """. But both ways it keeps giving me this error. In locally its run correctly when I pass the key like below.
Private Key.



Error :
2019-01-03T05:17:36.999Z dc94ff03-0f16-11e9-8f33-ad2618790c4d Error: Cannot parse privateKey: Unsupported key format



at Client.connect (/var/task/node_modules/ssh2/lib/client.js:230:13)
at SSH.start (/var/task/node_modules/simple-ssh/lib/ssh.js:214:19)
at exports.handler (/var/task/simplessh.js:72:4)


END RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d
REPORT RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d Duration: 153.03 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 22 MB

RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d Process exited before completing request



Code :



   const SSH = require('simple-ssh');

exports.handler = (event, context, callback) => {

var ssh = new SSH({
host: '00.000.000.000',
user: 'ubuntu',
port: 2202,
key : `-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAhDnPYbgBuZycHnei27TAKJ04FL7lmA+RwHD+Sre/swcZiAwe
OJDRlLsTJ/THis is not fully private key
veEWoxlRxTfRpR8/X4uuEeBJAGZnW99WLYoFBnWfFCxtNbyQwwSwwoyQxe13KAwC
-----END RSA PRIVATE KEY-----`

});



const subdomainName = 'staging-test2';

var migration = "&& php artisan tenant:migrate --subdomain=" + subdomainName + " --seed >> /tmp/seed.log";

var jsonstring = '{"company_name":"Apple","company_address":"123 Street Name","company_city":"Mexico","company_postcode":"3156","company_phone":"+41231321321","company_mobile":"+45564654654","company_fax":"+546465465465","company_email":"info@newtenant.local","company_country":"US","company_office":"Mexico","company_main_contact":"Ash Sutherland","company_email_domain":"newtenant.local"}'

var endStringStoredRegExWithEscape = undefined;

var re = new RegExp('"', 'g');

endStringStoredRegExWithEscape = jsonstring.replace(re, "\"") // /"/g saved regex

var concatWithlog = "&& php artisan tenant:new:seed --subdomain=" + subdomainName + " --data=" + """ + endStringStoredRegExWithEscape + """ + " >> /tmp/seed.log";
var re2 = new RegExp("//", 'g');
var serverArtisanPath = "cd /var/www/ib-dev-be/".replace(re2,"\/"); // "//g"

var currentPathCmd = "&& pwd";

const seed = concatWithlog;

var command = serverArtisanPath + currentPathCmd + migration + seed;

console.log("*********************************");
console.log("serverArtisanPath : ",serverArtisanPath);
console.log("migration : ", migration);
console.log("seed : ",seed);
console.log("*********************************");

ssh.exec(command, {
out: console.log.bind(console)
}).start();

};









share|improve this question































    0















    I been seeking for this problem and cannot find a proper solution for this.
    This is my code base. I have pass the Private KEY under private key and """ Private Key """. But both ways it keeps giving me this error. In locally its run correctly when I pass the key like below.
    Private Key.



    Error :
    2019-01-03T05:17:36.999Z dc94ff03-0f16-11e9-8f33-ad2618790c4d Error: Cannot parse privateKey: Unsupported key format



    at Client.connect (/var/task/node_modules/ssh2/lib/client.js:230:13)
    at SSH.start (/var/task/node_modules/simple-ssh/lib/ssh.js:214:19)
    at exports.handler (/var/task/simplessh.js:72:4)


    END RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d
    REPORT RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d Duration: 153.03 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 22 MB

    RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d Process exited before completing request



    Code :



       const SSH = require('simple-ssh');

    exports.handler = (event, context, callback) => {

    var ssh = new SSH({
    host: '00.000.000.000',
    user: 'ubuntu',
    port: 2202,
    key : `-----BEGIN RSA PRIVATE KEY-----
    MIIEowIBAAKCAQEAhDnPYbgBuZycHnei27TAKJ04FL7lmA+RwHD+Sre/swcZiAwe
    OJDRlLsTJ/THis is not fully private key
    veEWoxlRxTfRpR8/X4uuEeBJAGZnW99WLYoFBnWfFCxtNbyQwwSwwoyQxe13KAwC
    -----END RSA PRIVATE KEY-----`

    });



    const subdomainName = 'staging-test2';

    var migration = "&& php artisan tenant:migrate --subdomain=" + subdomainName + " --seed >> /tmp/seed.log";

    var jsonstring = '{"company_name":"Apple","company_address":"123 Street Name","company_city":"Mexico","company_postcode":"3156","company_phone":"+41231321321","company_mobile":"+45564654654","company_fax":"+546465465465","company_email":"info@newtenant.local","company_country":"US","company_office":"Mexico","company_main_contact":"Ash Sutherland","company_email_domain":"newtenant.local"}'

    var endStringStoredRegExWithEscape = undefined;

    var re = new RegExp('"', 'g');

    endStringStoredRegExWithEscape = jsonstring.replace(re, "\"") // /"/g saved regex

    var concatWithlog = "&& php artisan tenant:new:seed --subdomain=" + subdomainName + " --data=" + """ + endStringStoredRegExWithEscape + """ + " >> /tmp/seed.log";
    var re2 = new RegExp("//", 'g');
    var serverArtisanPath = "cd /var/www/ib-dev-be/".replace(re2,"\/"); // "//g"

    var currentPathCmd = "&& pwd";

    const seed = concatWithlog;

    var command = serverArtisanPath + currentPathCmd + migration + seed;

    console.log("*********************************");
    console.log("serverArtisanPath : ",serverArtisanPath);
    console.log("migration : ", migration);
    console.log("seed : ",seed);
    console.log("*********************************");

    ssh.exec(command, {
    out: console.log.bind(console)
    }).start();

    };









    share|improve this question



























      0












      0








      0








      I been seeking for this problem and cannot find a proper solution for this.
      This is my code base. I have pass the Private KEY under private key and """ Private Key """. But both ways it keeps giving me this error. In locally its run correctly when I pass the key like below.
      Private Key.



      Error :
      2019-01-03T05:17:36.999Z dc94ff03-0f16-11e9-8f33-ad2618790c4d Error: Cannot parse privateKey: Unsupported key format



      at Client.connect (/var/task/node_modules/ssh2/lib/client.js:230:13)
      at SSH.start (/var/task/node_modules/simple-ssh/lib/ssh.js:214:19)
      at exports.handler (/var/task/simplessh.js:72:4)


      END RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d
      REPORT RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d Duration: 153.03 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 22 MB

      RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d Process exited before completing request



      Code :



         const SSH = require('simple-ssh');

      exports.handler = (event, context, callback) => {

      var ssh = new SSH({
      host: '00.000.000.000',
      user: 'ubuntu',
      port: 2202,
      key : `-----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAhDnPYbgBuZycHnei27TAKJ04FL7lmA+RwHD+Sre/swcZiAwe
      OJDRlLsTJ/THis is not fully private key
      veEWoxlRxTfRpR8/X4uuEeBJAGZnW99WLYoFBnWfFCxtNbyQwwSwwoyQxe13KAwC
      -----END RSA PRIVATE KEY-----`

      });



      const subdomainName = 'staging-test2';

      var migration = "&& php artisan tenant:migrate --subdomain=" + subdomainName + " --seed >> /tmp/seed.log";

      var jsonstring = '{"company_name":"Apple","company_address":"123 Street Name","company_city":"Mexico","company_postcode":"3156","company_phone":"+41231321321","company_mobile":"+45564654654","company_fax":"+546465465465","company_email":"info@newtenant.local","company_country":"US","company_office":"Mexico","company_main_contact":"Ash Sutherland","company_email_domain":"newtenant.local"}'

      var endStringStoredRegExWithEscape = undefined;

      var re = new RegExp('"', 'g');

      endStringStoredRegExWithEscape = jsonstring.replace(re, "\"") // /"/g saved regex

      var concatWithlog = "&& php artisan tenant:new:seed --subdomain=" + subdomainName + " --data=" + """ + endStringStoredRegExWithEscape + """ + " >> /tmp/seed.log";
      var re2 = new RegExp("//", 'g');
      var serverArtisanPath = "cd /var/www/ib-dev-be/".replace(re2,"\/"); // "//g"

      var currentPathCmd = "&& pwd";

      const seed = concatWithlog;

      var command = serverArtisanPath + currentPathCmd + migration + seed;

      console.log("*********************************");
      console.log("serverArtisanPath : ",serverArtisanPath);
      console.log("migration : ", migration);
      console.log("seed : ",seed);
      console.log("*********************************");

      ssh.exec(command, {
      out: console.log.bind(console)
      }).start();

      };









      share|improve this question
















      I been seeking for this problem and cannot find a proper solution for this.
      This is my code base. I have pass the Private KEY under private key and """ Private Key """. But both ways it keeps giving me this error. In locally its run correctly when I pass the key like below.
      Private Key.



      Error :
      2019-01-03T05:17:36.999Z dc94ff03-0f16-11e9-8f33-ad2618790c4d Error: Cannot parse privateKey: Unsupported key format



      at Client.connect (/var/task/node_modules/ssh2/lib/client.js:230:13)
      at SSH.start (/var/task/node_modules/simple-ssh/lib/ssh.js:214:19)
      at exports.handler (/var/task/simplessh.js:72:4)


      END RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d
      REPORT RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d Duration: 153.03 ms Billed Duration: 200 ms Memory Size: 128 MB Max Memory Used: 22 MB

      RequestId: dc94ff03-0f16-11e9-8f33-ad2618790c4d Process exited before completing request



      Code :



         const SSH = require('simple-ssh');

      exports.handler = (event, context, callback) => {

      var ssh = new SSH({
      host: '00.000.000.000',
      user: 'ubuntu',
      port: 2202,
      key : `-----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAhDnPYbgBuZycHnei27TAKJ04FL7lmA+RwHD+Sre/swcZiAwe
      OJDRlLsTJ/THis is not fully private key
      veEWoxlRxTfRpR8/X4uuEeBJAGZnW99WLYoFBnWfFCxtNbyQwwSwwoyQxe13KAwC
      -----END RSA PRIVATE KEY-----`

      });



      const subdomainName = 'staging-test2';

      var migration = "&& php artisan tenant:migrate --subdomain=" + subdomainName + " --seed >> /tmp/seed.log";

      var jsonstring = '{"company_name":"Apple","company_address":"123 Street Name","company_city":"Mexico","company_postcode":"3156","company_phone":"+41231321321","company_mobile":"+45564654654","company_fax":"+546465465465","company_email":"info@newtenant.local","company_country":"US","company_office":"Mexico","company_main_contact":"Ash Sutherland","company_email_domain":"newtenant.local"}'

      var endStringStoredRegExWithEscape = undefined;

      var re = new RegExp('"', 'g');

      endStringStoredRegExWithEscape = jsonstring.replace(re, "\"") // /"/g saved regex

      var concatWithlog = "&& php artisan tenant:new:seed --subdomain=" + subdomainName + " --data=" + """ + endStringStoredRegExWithEscape + """ + " >> /tmp/seed.log";
      var re2 = new RegExp("//", 'g');
      var serverArtisanPath = "cd /var/www/ib-dev-be/".replace(re2,"\/"); // "//g"

      var currentPathCmd = "&& pwd";

      const seed = concatWithlog;

      var command = serverArtisanPath + currentPathCmd + migration + seed;

      console.log("*********************************");
      console.log("serverArtisanPath : ",serverArtisanPath);
      console.log("migration : ", migration);
      console.log("seed : ",seed);
      console.log("*********************************");

      ssh.exec(command, {
      out: console.log.bind(console)
      }).start();

      };






      node.js amazon-web-services aws-lambda format






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 14 at 5:13









      TRomesh

      1,65812036




      1,65812036










      asked Jan 3 at 5:44









      M.P.K DilshanM.P.K Dilshan

      13




      13
























          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016923%2fcannot-parse-privatekey-unsupported-key-format-aws-lambda-function-in-node%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016923%2fcannot-parse-privatekey-unsupported-key-format-aws-lambda-function-in-node%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          SQL update select statement

          'app-layout' is not a known element: how to share Component with different Modules