在Ubuntu中使用OpenSSL解密文件,需先安装OpenSSL,再根据加密方式选择对应命令,具体步骤如下:
安装OpenSSL
sudo apt update && sudo apt install openssl
对称加密(如AES-256-CBC)解密
openssl enc -d -aes-256-cbc -in encrypted_file.enc -out decrypted_file.txt -pass pass:your_password
-d:表示解密操作。-aes-256-cbc:指定加密算法和模式(若为其他算法,需替换,如-des)。-in:输入加密文件路径。-out:输出解密文件路径。-pass pass:your_password:指定解密密码(若密码存储在文件中,可替换为-pass file:/path/to/keyfile)。非对称加密(如RSA)解密
openssl rsautl -decrypt -in encrypted_file.enc -out decrypted_file.txt -inkey private_key.pem
-inkey:指定私钥文件路径。注意事项: