如何响应 bash 中的提示



我需要生成很多私钥和自签名证书,所以我想做一个 bash 脚本来为我做这件事。我遇到的问题是,当您对证书进行自签名时,它会询问与您生成签名请求相同的问题。

即:

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:  
State or Province Name (full name) [Some-State]: 
Locality Name (eg, city) []: 
Organization Name (eg, company) [Internet Widgits Pty Ltd]: 
Organizational Unit Name (eg, section) []: 
Common Name (e.g. server FQDN or YOUR name) []: 
Email Address []: 
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

我已经尝试了我在网站上看到的几件事,但似乎都没有奏效。这可能是因为我对 bash 很陌生。

我的脚本当前如下所示:

#!/bin/bash
openssl genrsa -out privkey.pem 2048
openssl req -new -key privkey.pem -out cert.csr

我尝试使用管道来回显我想输入的内容,但它不起作用。

有什么建议吗?

请参阅以下位置提供的示例:

http://www.openssl.org/docs/apps/req.html#EXAMPLES

或者在命令行中执行所有操作:

openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 
 -subj "/C=US/ST=Denial /L=Springfield/O=Dis/CN=www.example.com" 
 -keyout www.example.com.key  -out www.example.com.cert

相关内容

  • 没有找到相关文章

最新更新