0

I am trying to use AWS Secret manager to store a private ssh key and read in bash script. I created the secret with name testsshkey in Secrets manager. This is a multiline text stored in SecretsMananger Then I created the bash script with following

secret_key=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id testsshkey --query SecretString --output text)
echo $secret_key

When I run this script, it only prints last line of the key

miken32
  • 42,008
  • 16
  • 111
  • 154
Sudhir Jangam
  • 646
  • 2
  • 13
  • 20
  • 1
    Does this answer your question? [Capturing multiple line output into a Bash variable](https://stackoverflow.com/questions/613572/capturing-multiple-line-output-into-a-bash-variable) – miken32 Dec 10 '22 at 23:47
  • 2
    `echo "$secret_key"` – miken32 Dec 10 '22 at 23:48
  • 1
    See ["I just assigned a variable, but `echo $variable` shows something else"](https://stackoverflow.com/questions/29378566/i-just-assigned-a-variable-but-echo-variable-shows-something-else). The key probably also has DOS/Windows line endings, which cause all sorts of confusion in unix tools; see ["Are shell scripts sensitive to encoding and line endings?"](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings) – Gordon Davisson Dec 11 '22 at 00:32

0 Answers0