Security / Crypto Flashcards
OpenSSL: Generating a private RSA key, size 2048
Generating a private RSA key
openssl genrsa -out key.pem 2048
OpenSSL: Generating a private EC key
openssl ecparam -name prime256v1 -genkey -noout -out key.pem
my file encryption
openssl aes-256-cbc -pbkdf2 -salt -a -e -in .zshrc -out zshrc_encrypted
my file decryption
openssl aes-256-cbc -pbkdf2 -salt -a -d -in zshrc_encrypted -out zshrc_1
copy file to remote via ssh
rsync -aPv -e “ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ~/.ssh/gitlab_brainloop” ~/Documents/tmp.csv gludwig@10.254.40.16:/home/gludwig/tmp1.csv
ssh: Preferred Authentications
~/.ssh/config -> PreferredAuthentications=publickey
ssh -o “PreferredAuthentications=password” username@example.com
ssh: detect “Failed SSH login Attempts”
using ‘secure log’ files
egrep “Failed|Failure” /var/log/secure
ssh: Disable DNS Lookup On Remote Machine
/etc/ssh/sshd_config
UseDNS=no
ssh: how to handle “Too many authentication failures” on cli
ssh -i home_fedora -o IdentitiesOnly=yes gludwig@192.168.188.30
add new user - secured it with ssh key - disable password
adduser -c ‘comment’ -d /home/username -G wheel –no-user-group –shell /bin/bash username
ssh-keygen -b 4096 -t ed25519 -f keyname
ssh-keygen -l keyname
cat .ssh/id_rsa.pub | ssh sheena@192.168.0.11 ‘cat»_space; .ssh/authorized_keys’
or
ssh sheena@192.168.0.11 “chmod 700 .ssh; chmod 640 .ssh/authorized_keys”
cat gcp-centos8.pub | ssh -i gcp-centos8 h19900401_gmail_com@34.76.188.251 “sudo mkdir /home/gludwig/.ssh && sudo touch /home/gludwig/.ssh/authorized_keys && sudo chmod -R go= /home/gludwig/.ssh && sudo cat»_space; /home/gludwig/.ssh/authorized_keys && sudo chown gludwig:users /home/gludwig/.ssh/authorized_keys”
or
ssh-copy-id -i ~/.ssh/mykey user@host
sudo vi /etc/ssh/sshd_config ... PasswordAuthentication no ... sudo systemctl restart sshd
vi /etc/ssh/sshd_config PermitRootLogin no OR PermitRootLogin without-password ... systemctl restart sshd
check IP and DNS
https://ipleak.net/
OpenSSL: Extract the public key from the key pair, which can be used in a certificate
openssl rsa -in key.pem -outform PEM -pubout -out public.pem
OpenSSL: get length of rsa key
openssl rsa -in aws-secret.priv -text -noout | grep Private
OpenSSL: extract the public key from private EC key
openssl ec -in key.pem -pubout -out public.pem
ssh: detect “Failed SSH login Attempts”
using ‘auth log’ file
grep “Failed password” /var/log/auth.log | awk ‘{print $11}’ | uniq -c | sort -nr