ssh port forwarding

Updated: 16 November 2023

What’s ssh port forwarding and what’s the difference between ssh local and remote port forwarding

-R Specifies that connections to the given TCP port or Unix socket on the remote (server) host are to be forwarded to the local side.
-L Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the remote side.

SSL

Updated: 27 June 2024

Diagnose problems with certificates

Create self-signed certificates for Apache

https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-20-04

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/ssl/private/apache-selfsigned.key \
-out /etc/ssl/certs/apache-selfsigned.crt

bash

Updated: 21 July 2023

Documentation

Bash guide for beginners
Bash reference manual
Bash reference manual

Miscellaneous

Shorten prompt in current terminal
PS1='\u:\W\$ '

Exit status of last command
echo $?

Repeat a command n times
for run in {1..100}; do command; sleep 5; done

Run A and then B, regardless of success of A
A; B

Run B if and only if A succeeded
A && B

Run B if and only if A failed
A || B

Run A in background.
A &

GoAccess

Updated: 07 July 2024

https://goaccess.io/

GoAccess is an open source real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.


Connect to your webserver via ssh and pipe the access log to goaccess running locally in Docker. Create a report in html format.

ssh user@example.com 'cat /var/log/apache2/the-domain.co.uk.conf/access.log' | \
docker run --rm -i -e LANG=$LANG allinurl/goaccess -a -o html --log-format COMBINED - > report.html

Connect to your webserver via ssh and pipe the access log to goaccess running locally. Create a report in html format.

ssh user@<ip address> 'cat /var/log/apache2/example.com-le-ssl.conf/access.log' | \
goaccess -a -o ~/report.html --log-format=COMBINED --html-report-title="example.com logs" -

DNS

Updated: 13 September 2024

DNS Records

Type Purpose Note
CNAME Points subdomain to another website (not an IP). Will forward all requests and ignore other records.
ALIAS Points domain to another website (not an IP). Cannot already be an A or AAAA record on the bare domain @.
A Point domain to a static IPV4 address.

DNS Lookup

Cloudflare recommended 3rd party tools
Digital Ocean DNS Lookup


dig

Query for information on all DNS records

dig your_domain_name.com ANY

Query for A records

dig your_domain_name.com A

host, nslookup and dig share similar functionality.


Use the host dns lookup utility to lookup nameserver records

host -t ns example.com

whois

The ICANN registration data lookup tool gives you the ability to look up the current registration data for domain names

https://lookup.icann.org/en

Return information about a domain name registration, including the name servers it is configured to work with

whois your_domain_name.com

PHPDoc

Updated: 06 May 2024

PHPDoc reference

Generate php documentation with phpdoc tool and Docker

docker pull phpdoc/phpdoc
cd path/to/my-php-project
docker run --rm -v $(pwd):/data phpdoc/phpdoc -d src -t doc

Display cli manual

docker run --rm phpdoc/phpdoc --help