Skip to content

Instantly share code, notes, and snippets.

@loujaybee
Last active June 3, 2022 15:09
Show Gist options
  • Save loujaybee/92256907ee838ea8068b25dd61cb43b5 to your computer and use it in GitHub Desktop.
Save loujaybee/92256907ee838ea8068b25dd61cb43b5 to your computer and use it in GitHub Desktop.
--- node convert-key.js
var fs = require("fs");
var stdinBuffer = fs.readFileSync(0); // STDIN_FILENO = 0
const key = stdinBuffer.toString()
const start = "-----BEGIN RSA PRIVATE KEY----- ";
const end = "-----END RSA PRIVATE KEY-----";
const rawKey = key.replace(start, '').replace(end, '').replaceAll(' ', '\n').slice(0,-2).concat(end).replace (/^/, `${start}\n`);
console.log(rawKey);
--- gitpod.yml
tasks:
- name: "ssh"
command: >
echo $PEM | node convert-key.js >> temp.pem &&
chmod 600 temp.pem &&
gp sync-done download-key &&
ssh -i temp.pem ubuntu@website.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment