Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a Linux/Unix command-line tool to create a DSA signature from a given file/data and a private key

I know about the xmlsec1 tool from:

But I would like something simpler. The openssl tool doesn't appear to have this function. It seems that OpenSSL provides this function as a developer library, but not as a tool.


share|improve this question

It's done with "openssl dgst" - not the most obvious place to put it...

Found in:

openssl dsaparam 1024 < /dev/random > dsaparam.pem

openssl gendsa dsaparam.pem -out dsa_priv.pem

openssl dsa -in dsa_priv.pem -pubout -out dsa_pub.pem

echo "foobar" > foo.txt

sha1sum < foo.txt | awk '{print $1}' > foo.sha1

openssl dgst -dss1 -sign dsa_priv.pem foo.sha1 > sigfile.bin

openssl dgst -dss1 -verify dsa_pub.pem -signature sigfile.bin foo.sha1

share|improve this answer

Have you looked at:

share|improve this answer
Yes, these manage the keys, but don't encrypt/decrypt. – mparaz Jan 9 '11 at 8:44

Do you want to create a signature for a file such that the integrity of that file can be verified? I think you're looking for Gnu Privacy Guard (GnuPG).

gpg --output filename.sig --detach-sig filename

This creates a signature file, filename.sig, based on the original, filename, that can be verified with

gpg --verify filename.sig filename
share|improve this answer
Was looking for something simpler, just using the DSA private key without GPG infrastructure, but let me see if this will do. – mparaz Jan 9 '11 at 8:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.