Skip to content

Instantly share code, notes, and snippets.

@jasonsouza
Last active June 3, 2021 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonsouza/f882e9c2b7a037a963fcf6aceb5e1965 to your computer and use it in GitHub Desktop.
Save jasonsouza/f882e9c2b7a037a963fcf6aceb5e1965 to your computer and use it in GitHub Desktop.
Convert private SSH key for JSON value format
#!/bin/bash
# Requires AWk and SED to be installed.
export SSH_FILE_PATH="$HOME/.ssh/id_rsa" #replace this with path to your private SSH key
line_count=`wc -l ${SSH_FILE_PATH} | awk '{print $1}'`
last_new_line=`expr $line_count - 1`
cat $SSH_FILE_PATH | sed '1s/$/\\n/' | sed ""$last_new_line"s/$/\\\n/" | tr -d '\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment