The context is that I want to write a /tmp/policy.hcl file inside a HashiCorp Vault container from a remote machine that I can then use to write a policy. I am struggling to preserve the double quotes in the file.
#!/bin/sh
function send {
sshpass -p mypassword ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" "root@${1}" "${2}"
}
send "${host}" "kubectl -n ${namespace} exec pod/vault-0 -- sh -c 'echo path "secret/*" { capabilities = ["create", "read", "update", "delete", "list"]} > /tmp/policy.hcl'"
# kubectl -n vault exec -it pod/vault-0 -- cat /tmp/policy.hcl
path secret/* { capabilities = [create, read, update, delete, list]}
The content should be path "secret/*" { capabilities = ["create", "read", "update", "delete", "list"]}
. I’ve tried various combinations of escaping and single/double quote usage but they all have similar results.
1