温馨提示×

ubuntu openssl解密步骤怎样

小樊
44
2025-09-05 02:55:22
栏目: 云计算

在Ubuntu上使用OpenSSL解密,步骤如下:

  1. 安装OpenSSL(若未安装):

    sudo apt update && sudo apt install openssl 
  2. 确定加密算法

    • 若为AES对称加密(如.enc文件),需知道具体模式(如-aes-256-cbc)。
    • 若为RSA非对称加密(如.pem私钥加密),需对应的私钥文件。
  3. 执行解密命令

    • AES解密
      openssl enc -d -aes-256-cbc -in encrypted_file.enc -out decrypted_file -pass pass:your_password 
      -pass可替换为-pass file:/path/to/keyfile指定密码文件)
    • RSA解密
      openssl rsautl -decrypt -inkey private_key.pem -in encrypted_file.enc -out decrypted_file 
      (若私钥有密码,需添加-passin pass:your_password
  4. 注意事项

    • 避免在命令行直接输入敏感密码,可通过环境变量或密码文件传递。
    • 确保私钥文件权限安全(仅授权用户可读)。
    • 大文件建议用对称加密(如AES)结合RSA加密密钥,而非直接用RSA加密大文件。

根据加密方式选择对应命令,执行后解密文件会保存至指定路径。

0