【问题标题】:How to pass authorization key in shell script curl command without header如何在没有标头的shell脚本curl命令中传递授权密钥
【发布时间】:2022-01-24 23:16:16
【问题描述】:

在 shell 脚本中,我需要从 .pem 文件中提取私钥。当我将我的AUTORIZATION 变量设置为路径时,该变量只是文件路径字符串,而不是实际的文件路径。

如果我将AUTHORIZATION 变量更改为cat <FILE_PATH>,它会导入页眉和页脚,即-----BEGIN RSA PRIVATE KEY... END RSA PRIVATE KEY-----

如何提取没有页眉和页脚的 RSA 密钥?

CLUSTER=standalone
TENANT=climate
NAMESPACE=integration_test
AUTHORIZATION=$REPO_ROOT/pulsar/tls/broker/broker.key.pem

echo $AUTHORIZATION

# Create tenant
curl -L -X PUT "http://localhost:$HOST_PULSAR_PORT/admin/v2/tenants/$TENANT" \
    --header "Authorization: Bearer $AUTHORIZATION" \
    --header 'Content-Type: application/json' \
    --data-raw "{\"allowedClusters\": [\"$CLUSTER\"]}"

【问题讨论】:

    标签: curl oauth-2.0 sh rsa cat


    【解决方案1】:

    您可以使用cat 从文件位置获取输出,然后将其存储到变量中

    AUTHORIZATION=$(cat $REPO_ROOT/pulsar/tls/broker/broker.key.pem)
    

    You may refer to this question

    【讨论】:

      猜你喜欢
      • 2012-10-31
      • 1970-01-01
      • 2013-01-21
      • 2017-04-11
      • 2018-02-26
      • 1970-01-01
      • 1970-01-01
      • 2014-01-15
      • 2014-10-03
      相关资源
      最近更新 更多