Difference between revisions of "OpenSSL/Cheatsheet"

From braindump
Jump to navigation Jump to search
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Command line shortcuts ==
== Command line shortcuts ==
=== Base64 ===
Encode
openssl base64 < file.b64 > file.txt


{| class="wikitable sortable collapsible"
Decode
|-
openssl base64 -d < file.txt > file.b64
! Type !! Action !! Command !! Comment
|-
| Help || List || <tt>openssl list-standard-commands</tt> ||
|-
| Base64 || Encode || <tt>openssl base64 -in <span class="input"><INPUT>.txt</span> -out <span class="input"><OUTPUT>.b64</span></tt> ||
|-
| Base64 || Decode || <tt>openssl base64 -d -in <span class="input"><File>.b64</span> -out <span class="input"><File>.txt</span></tt> ||
|-
| MD5 || Checksum || <tt>openssl md5 <span class="input"><File></span> </tt> || Same as <tt>md5sum <span class="input"><File></span></tt>
|-
| SHA1 || Checksum || <tt>openssl sha1 <span class="input"><File></span> </tt> || Same as <tt>sha1sum <span class="input"><File></span></tt>
|-
| SHA224 || Checksum || <tt>openssl sha224 <span class="input"><File></span> </tt> || Same as <tt>sha224sum <span class="input"><File></span></tt>
|-
| SHA256 || Checksum || <tt>openssl sha256 <span class="input"><File></span> </tt> || Same as <tt>sha256sum <span class="input"><File></span></tt>
|-
| SHA384 || Checksum || <tt>openssl sha384 <span class="input"><File></span> </tt> || Same as <tt>sha384sum <span class="input"><File></span></tt>
|-
| SHA512 || Checksum || <tt>openssl sha512 <span class="input"><File></span> </tt> || Same as <tt>sha512sum <span class="input"><File></span></tt>
|-
| Password || Encrypt || <tt>openssl passwd <span class="input"><Password></span> </tt> || Creates a crypt-ed password for use with <tt>/etc/shadow</tt> [1]
|-
| Password || Encrypt || <tt>openssl passwd -1 <span class="input"><Password></span> </tt> || Creates a md5 password for use with <tt>/etc/shadow</tt> [1]
|-
|}


=== MD5 ===
=== Notes ===
# Newer versions of Debian use the sha-512 there is a tool called <tt>mkpasswd</tt> that will create compatible passwords.
Checksum a file
openssl md5 file

=== SHA1 ===
Checksum a file
openssl sha1 file


=== Generate Passwords ===
Crypt
openssl passwd <span class="input"><Password></span>

MD5 (for /etc/passwd and /etc/shadow)
openssl passwd -1


=== File encryption ===
=== File encryption ===
Encrypt
Encrypt
openssl enc -aes-256-cbc < <span class="input"><File></span> > <span class="input"><File></span>.aes
openssl enc -aes-256-cbc -in <span class="input"><File></span> -out <span class="input"><File></span>.aes
enter aes-256-cbc encryption password:
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:

Encrypt with password from file
openssl enc -aes-256-cbc -pass file:<span class="input"><PwFile></span>> -in <span class="input"><File></span> -out <span class="input"><File></span>.aes



Decrypt
Decrypt
openssl enc -d -aes-256-cbc -in <span class="input"><File></span>.aes > <span class="input"><File></span>
openssl enc -d -aes-256-cbc -in <span class="input"><File></span>.aes -out <span class="input"><File></span>
enter aes-256-cbc decryption password:
enter aes-256-cbc decryption password:


Decrypt with password from file
openssl enc -d -aes-256-cbc -pass file:<span class="input"><PwFile></span> -in <span class="input"><File></span>.aes -out <span class="input"><File></span>
[[Category:OpenSSL]]
[[Category:OpenSSL]]

Latest revision as of 08:27, 4 October 2015

Command line shortcuts

Type Action Command Comment
Help List openssl list-standard-commands
Base64 Encode openssl base64 -in <INPUT>.txt -out <OUTPUT>.b64
Base64 Decode openssl base64 -d -in <File>.b64 -out <File>.txt
MD5 Checksum openssl md5 <File> Same as md5sum <File>
SHA1 Checksum openssl sha1 <File> Same as sha1sum <File>
SHA224 Checksum openssl sha224 <File> Same as sha224sum <File>
SHA256 Checksum openssl sha256 <File> Same as sha256sum <File>
SHA384 Checksum openssl sha384 <File> Same as sha384sum <File>
SHA512 Checksum openssl sha512 <File> Same as sha512sum <File>
Password Encrypt openssl passwd <Password> Creates a crypt-ed password for use with /etc/shadow [1]
Password Encrypt openssl passwd -1 <Password> Creates a md5 password for use with /etc/shadow [1]

Notes

  1. Newer versions of Debian use the sha-512 there is a tool called mkpasswd that will create compatible passwords.

File encryption

Encrypt

openssl enc -aes-256-cbc -in <File> -out <File>.aes
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:

Encrypt with password from file

openssl enc -aes-256-cbc -pass file:<PwFile>> -in <File> -out <File>.aes


Decrypt

openssl enc -d -aes-256-cbc -in <File>.aes -out <File> 
enter aes-256-cbc decryption password:

Decrypt with password from file

openssl enc -d -aes-256-cbc -pass file:<PwFile> -in <File>.aes -out <File>