One of our Apps github-backup requires the use of an RSA Private Key as an Environment Variable.
Simply attempting to export the key it in the terminal e.g:
te
What I wanted is one and only one executable shell script containing it all, and not 1 script and 1 .pem file and then doing some gymnastics in between, like what I am seeing in the existing answers so far.
To achieve this unification, all that is needed is the following. Preparation phase:
cat id_rsa | base64 -w0
# assign the converted 1-liner string wrap in single quote into a shell variable, for example
pk='xxxxxxxxxxxyyyyyyyyyyzzzzzzzzzzz......'
The rest is walk-in-the park. To ssh using variable pk you will convert back the 1-liner string into its original posture and write to a temporary file.
t=$(mktemp)
printf $pk | base64 --decode > $t
ssh -i $t smeagol@192.143.69.69
To clean-up, use the trap:
trap cleanup 1 2 3 6
cleanup () {
rm -f $t
}
To improve security, modify mktemp so write somewhere within your $HOME folder where only you can read, rather than in /tmp where other users in the same server can read.