阅读量:4
以下是一些Ubuntu下OpenSSL命令行的使用技巧:
安装与验证
- 安装OpenSSL:
sudo apt update,sudo apt install openssl。 - 验证安装:
openssl version。
加密与解密
- 对称加密(AES-256-CBC):加密文件
openssl enc -aes-256-cbc -salt -in input.txt -out encrypted.enc,解密文件openssl enc -d -aes-256-cbc -in encrypted.enc -out decrypted.txt。 - 非对称加密(RSA):生成密钥对
openssl genrsa -out private.pem 2048,openssl rsa -in private.pem -pubout -out public.pem;用公钥加密openssl rsautl -encrypt -inkey public.pem -pubin -in file.txt -out encrypted.enc,用私钥解密openssl rsautl -decrypt -inkey private.pem -in encrypted.enc -out decrypted.txt。
证书操作
- 生成自签名证书:
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes。 - 查看证书信息:
openssl x509 -in cert.pem -text -noout。
其他常用操作
- 生成随机密钥:
openssl rand -hex 32 > key.txt。 - 计算文件哈希值:
openssl sha256 file.zip。 - 调试SSL连接:
openssl s_client -connect example.com:443 -verbose。
以上就是关于“Ubuntu下OpenSSL命令行使用技巧”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm