Security Cheatsheet

Essential security commands and best practices for SSL/TLS, SSH, encryption, and network security. Keep your systems and data protected.

SSL/TLS

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes

Generate self-signed SSL certificate

openssl x509 -in cert.pem -text -noout

View certificate details

openssl s_client -connect example.com:443

Test SSL connection

openssl verify cert.pem

Verify certificate

openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt

Convert certificate to PKCS#12 format

SSH

ssh-keygen -t ed25519 -C "your_email@example.com"

Generate SSH key pair

ssh-copy-id user@remote_host

Copy SSH key to remote server

ssh -i /path/to/private_key user@remote_host

Connect using specific private key

ssh -L 8080:localhost:80 user@remote_host

Create SSH tunnel

ssh -D 8080 user@remote_host

Create SOCKS proxy

Password Management

openssl rand -base64 32

Generate secure random password

echo -n 'password' | openssl dgst -sha256

Generate SHA-256 hash

echo -n 'password' | openssl dgst -sha512

Generate SHA-512 hash

openssl passwd -1 'password'

Generate MD5 password hash

openssl rand -hex 16

Generate random hex string

Network Security

nmap -sV -p- <target>

Scan all ports and detect versions

nmap -sS -p 80,443 <target>

TCP SYN scan specific ports

nmap -sU -p 53,123 <target>

UDP scan specific ports

nmap -A -T4 <target>

Aggressive scan with timing

nmap --script ssl-cert <target>

Check SSL certificate

File Encryption

gpg --gen-key

Generate GPG key pair

gpg --encrypt --recipient user@example.com file.txt

Encrypt file for specific recipient

gpg --decrypt file.txt.gpg

Decrypt GPG encrypted file

gpg --export --armor user@example.com > public.key

Export public key

gpg --import public.key

Import public key

Security Tools

curl -I https://example.com

Check security headers

openssl s_client -connect example.com:443 -servername example.com

Check SSL/TLS configuration

dig +short TXT _dmarc.example.com

Check DMARC record

dig +short MX example.com

Check MX records

dig +short TXT example.com

Check TXT records