Jacques Delsemme

Linux Cheat Sheet

Linux commands that I don't use very often, and need help remembering the exact syntax.

telnet to an SSL port

Because you cannot use telnet because of encryption, use openssl instead:

openssl s_client -connect host.ucsc.edu:443 -state -quiet

then type:

GET / HTTP/1.0	+ 2 RETURNs

Port check

Check if a port (e.g. 80) is open:

nmap host.ucsc.edu -p 80
Interpreting results
open app listening on that port
filtered firewall hiding port, cannot infer status
closed no app is listening now, but could be
unfiltered respond to nmap, but cannot tell whether open or closed

Alternatively if nmap is not available use:

nc -w 2 -z host.ucsc.edu 80
It will only reply if successful.

SSL certificates

Scan for SSL ciphers

sslscan --no-failed host.ucsc.edu:443

Check certificate valid dates

echo | openssl s_client -connect host.ucsc.edu:443 2>/dev/null | openssl x509 -dates -noout

Examine SSL certificate

openssl req  -noout -text -in cert.csr
openssl x509 -noout -text -in cert.crt

Create SSL certificate in 3 steps

  1. Generate key
    openssl genrsa 2048 > cert.key
    
  2. Generate request
    openssl req -new -key cert.key > cert.csr
    
  3. Generate self-signed certificate (or submit cert.csr to a CA):
    openssl req -x509 -key cert.key -in cert.csr > cert.crt
    

Install the cert.key and cert.crt files in apache. This key is not password protected so that apache can restart without requiring a prompt. Thus protect the key with suitable permissions.

Verify SSL certificate

openssl verify -purpose sslserver -CAfile chain.crt cert.crt

Check database connection

mysql -h mysql_hostname -u db_user -p 

Check cnames

dig ucsc.edu axfr | grep as-prod-web-vip70 | sort

Prevent ssh disconnects

If you get disconnected after a few minutes of inactivity when using ssh, add this line to your ssh config file:

ServerAliveInterval 90

On linux, the file is in /etc/ssh/ssh_config; it could be something similar sounding on a Mac or in Windows.

W3C validators: check nu css links https://www.delsemme.org/jacques/howtos/tips.php
Last modified Sunday, January 1, 2017 @ 09:44pm
Contact