Skip to content

Instantly share code, notes, and snippets.

@mikeplate
Last active October 22, 2021 13:43
Show Gist options
  • Save mikeplate/3b90914b28461520974b15b61c9d0177 to your computer and use it in GitHub Desktop.
Save mikeplate/3b90914b28461520974b15b61c9d0177 to your computer and use it in GitHub Desktop.
Linux Bash Snippets
# Start reverse SSH tunnel from internal server to external endpoint on port 443
# Port 8081 on external endpoint will then be connectable to internal server localsql port 1433
ssh -N -R 0.0.0.0:8081:localsql:1433 remoteuser@company-endpoint.westeurope.cloudapp.azure.com -p 443 -i ./remoteuser.pem
# Show certificate for SMTP server with implicit TLS
openssl s_client -connect smtp.some-server.com:465 -servername smtp.some-server.com
# Show certificate for SMTP server with explicit TLS
openssl s_client -connect smtp.some-server.com:587 -servername smtp.some-server.com -starttls smtp
# Fetch date from an API where URL is stored in sqlite database and set locally as a replacement for NTP
sqlite3 /opt/owi/SqlOWI.db "select Value from AppSettings where Key='ApiUrl'" | xargs -i curl -s {}/_api/check | grep -oP \(\?\<=\time\":\"\)[^\"]+ | xargs -i date --set={}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment