openssl Verified current stable Not installed? Security

Openssl / Sign File With Rsa Key

Sign File With Rsa Key

Use OpenSSL to sign a file with an RSA private key using SHA-256 and PSS padding.

$
Terminal
openssl dgst -sign <private_key_file> -sha256 -sigopt rsa_padding_mode:pss -out <output_file> <input_file>

When To Use

This command is used to digitally sign a file for verification purposes.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
openssl dgst -sign <private_key_file> -sha256 -sigopt rsa_padding_mode:pss -out <output_file> <input_file>

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
Signature written to output_file

Command Breakdown

What each part is doing

openssl
Base Command
The executable that performs this operation. Here it runs Openssl before the shell applies any redirect operators.
<private_key_file>
Input Files
The file path or paths supplied to this command.
<output_file>
Input Files
The file path or paths supplied to this command.
<input_file>
Input Files
The file path or paths supplied to this command.
-sign
Command Option
Tool-specific option used by this command invocation.
-sha256
Command Option
Tool-specific option used by this command invocation.
-sigopt
Command Option
Tool-specific option used by this command invocation.
-out
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Replace {{private_key_file}} with your RSA private key file path.

  2. Step 2

    Specify {{input_file}} as the file you want to sign.

  3. Step 3

    Set {{output_file}} to the desired output file path for the signature.

Alternative Approaches

Comparable commands in other tools

Alternative security tools for the same job.