小编The*_*Guy的帖子

以非交互方式创建 SSL 证书

我想默默地,非交互地,创建一个 SSL 证书。即,没有得到任何数据的提示。

我创建证书的正常方式是:

openssl req -x509 -nodes -days 7300 -newkey rsa:2048 \
    -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem 
Run Code Online (Sandbox Code Playgroud)

我尝试了以下方法:

openssl genrsa -out server.key 2048
touch openssl.cnf

cat >> openssl.cnf <<EOF
[ req ]
prompt = no
distinguished_name = req_distinguished_name

[ req_distinguished_name ]
C = GB
ST = Test State
L = Test Locality
O = Org Name
OU = Org Unit Name
CN = Common Name
emailAddress = test@email.com
EOF

openssl req -x509 -config openssl.cnf -nodes -days 7300 \
    -signkey server.key …
Run Code Online (Sandbox Code Playgroud)

scripting ssl

42
推荐指数
1
解决办法
4万
查看次数

第 4 行:$data:使用密码框时的歧义重定向

我想使用对话框包创建一个密码框。

#!/bin/bash
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title "Password" \
--clear \
--passwordbox "Enter your password" 10 30 2> $data

ret=$?

case $ret in
  0)
    echo "Password is $(cat $data)";;
  1)
    echo "Cancel pressed.";;
  255)
    [ -s $data ] &&  cat $data || echo "ESC pressed.";;
esac
Run Code Online (Sandbox Code Playgroud)

但是,当我执行它时出现此错误:

line 4: $data: ambiguous redirect
Run Code Online (Sandbox Code Playgroud)

怎么了?

io-redirection shell-script dialog

3
推荐指数
1
解决办法
2万
查看次数

猫在里面写带有“$”的文字

我想将配置信息写入一个包含美元符号 ( $)的特定文件。这似乎是一个问题。

这是我所做的:

$ cat >> /etc/nginx/nginx.conf <<EOF
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user              nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    ## Detect when HTTPS is used
    map $scheme $https {
      default off;
      https on;
    }
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" …
Run Code Online (Sandbox Code Playgroud)

shell quoting cat here-document

3
推荐指数
1
解决办法
1069
查看次数