From 622333d00fc7bb752460d2b4bf7b2de3d85eb8c8 Mon Sep 17 00:00:00 2001 From: trimstray Date: Thu, 7 Feb 2019 19:42:17 +0100 Subject: [PATCH] updated openssl/find one-liners - signed-off-by: trimstray --- README.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f12eb84..3f6745d 100644 --- a/README.md +++ b/README.md @@ -1227,6 +1227,12 @@ find -xdev -samefile filename find . -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr | cut -d: -f2- | head ``` +###### Recursively find/replace of a string with awk or sed + +```bash +find . -not -path '*/\.git*' -type f -print0 | xargs -0 sed -i 's/foo/bar/g' +``` + ___ ##### Tool: [top](https://en.wikipedia.org/wiki/Top_(software)) @@ -1513,7 +1519,7 @@ openssl s_client -cipher 'AES128-SHA' -connect google.com:443 openssl genrsa -out ${_fd} ${_len} ) ``` -###### Generate private key with password +###### Generate private key with passphrase ```bash # _ciph: des3, aes128, aes256 @@ -1522,13 +1528,28 @@ openssl genrsa -out ${_fd} ${_len} ) openssl genrsa -${_ciph} -out ${_fd} ${_len} ) ``` -###### Remove password from private key +###### Remove passphrase from private key ```bash ( _fd="private.key" ; _fd_unp="private_unp.key" ; \ openssl rsa -in ${_fd} -out ${_fd_unp} ) ``` +###### Encrypt existing private key with a passphrase + +```bash +# _ciph: des3, aes128, aes256 +( _ciph="aes128" ; _fd="private.key" ; _fd_pass="private_pass.key" ; \ +openssl rsa -${_ciph} -in ${_fd} -out ${_fd_pass} +``` + +###### Check private key + +```bash +( _fd="private.key" ; \ +openssl rsa -check -in ${_fd} ) +``` + ###### Get public key from private key ```bash @@ -1590,6 +1611,33 @@ EOF )) ``` +###### Generate ECDSA private key + +```bash +# _curve: X25519, prime256v1, secp521r1, secp384r1 +( _fd="private.key" ; _curve="prime256v1" ; \ +openssl ecparam -out ${_fd} -name ${_curve} -genkey ) +``` + +###### Print ECDSA private and public keys + +```bash +( _fd="private.key" ; \ +openssl ec -in ${_fd} -noout -text ) +``` + +###### List available EC curves + +```bash +openssl ecparam -list_curves +``` + +###### Generate private key with csr (ECC) + +```bash +( _fd="domain.com.key" ; _fd_csr="domain.com.csr" ; _curve="prime256v1" ; openssl ecparam -out ${_fd} -name ${_curve} -genkey ; openssl req -new -key ${_fd} -out ${_fd_csr} -sha256 ) +``` + ###### Convert DER to PEM ```bash