阅读量:4
Linux OpenSSL命令非常丰富,以下是一些常用的OpenSSL命令及其功能:
基础命令
-
查看版本
openssl version -
生成随机数
openssl rand -base64 12 -
生成私钥
openssl genrsa -out private.key 2048 -
生成公钥
openssl rsa -in private.key -pubout -out public.key -
生成证书签名请求(CSR)
openssl req -new -key private.key -out request.csr -
自签名证书
openssl req -x509 -new -nodes -key private.key -sha256 -days 365 -out certificate.crt -
验证证书
openssl verify -CAfile ca.crt certificate.crt -
加密文件
openssl enc -aes-256-cbc -salt -in plaintext.txt -out encrypted.txt -pass pass:mypassword -
解密文件
openssl enc -d -aes-256-cbc -in encrypted.txt -out decrypted.txt -pass pass:mypassword -
查看证书信息
openssl x509 -in certificate.crt -text -noout
SSL/TLS相关命令
-
测试SSL/TLS连接
openssl s_client -connect example.com:443 -
获取服务器证书
openssl s_client -connect example.com:443 -showcerts /dev/null | openssl x509 -outform PEM > example.com.pem -
生成SSL/TLS配置文件
openssl req -new -x509 -days 365 -nodes -out ca.crt -keyout ca.key openssl req -newkey rsa:2048 -days 365 -nodes -keyout server.key -out server.csr openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 365 -sha256
PKCS#12相关命令
-
生成PKCS#12文件
openssl pkcs12 -export -in certificate.crt -inkey private.key -out keystore.p12 -name mycert -
导入PKCS#12文件
openssl pkcs12 -in keystore.p12 -out certificate.crt -clcerts -nokeys openssl pkcs12 -in keystore.p12 -out private.key -nocerts -nodes
其他有用的命令
-
生成Diffie-Hellman参数
openssl dhparam -out dhparams.pem 2048 -
生成DSA密钥对
openssl dsaparam -out dsaparam.pem 2048 openssl gendsa -out dsa_private.key dsaparam.pem openssl dsa -in dsa_private.key -pubout -out dsa_public.pem -
生成EC密钥对
openssl ecparam -name secp384r1 -genkey -noout -out ec_private.key openssl ec -in ec_private.key -pubout -out ec_public.pem -
签名数据
openssl dgst -sha256 -sign private.key -out signature.bin data.txt -
验证签名
openssl dgst -sha256 -verify public.key -signature signature.bin data.txt
注意事项
- 使用这些命令时,请确保你有足够的权限和了解其潜在风险。
- 在处理敏感信息(如私钥和密码)时要格外小心。
- 定期更新你的OpenSSL版本以获取最新的安全补丁。
以上只是OpenSSL命令的一部分,更多详细信息和高级用法可以参考OpenSSL的官方文档或使用man命令查看具体命令的手册页。
以上就是关于“Linux OpenSSL命令有哪些”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm