Skip to content

Instantly share code, notes, and snippets.

View schneefisch's full-sized avatar

Florian schneefisch

View GitHub Profile
@schneefisch
schneefisch / generate_keypair.md
Last active November 15, 2022 15:37
Generate a new keypair with OpenSSL

How to generate an RSA Keypair

Generate a certificate (PEM)

For more security use -aes512 4096

openssl genrsa -out key.pem -aes256 2048

Extract public key as PEM

@schneefisch
schneefisch / openssl_certificates.md
Last active December 18, 2023 09:41
Convert certificate formats with OpenSSL

Various certificate-conversions

Exports

Export public certificate/key from pfx

openssl pkcs12 -in <cert>.pfx -clcerts -nokeys -out <pub_cert>.pem

Export certificate

@schneefisch
schneefisch / keytool_basics.sh
Last active September 14, 2020 09:06
Java keytool basic usage
#!/bin/bash
# more shortcuts at https://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html
# list certificates included in a keystore
keytool -list -v -keystore keystore.jks
# with specific storetype:
keytool -list -v -storetype jceks keystore.jks
# check a specific certificate
keytool -printcert -v -file mydomain.crt
@schneefisch
schneefisch / netstat_basics.sh
Last active September 27, 2020 17:35
basics for netstat
# check active connections
netstat -ant | grep 4444 | wc -l
# only established connections
netstat -ant | grep 4444 | grep -i established | wc -l
# idle connections
netstat -an -f inet | grep -v EST | grep IDLE | wc -l
# in loop
@schneefisch
schneefisch / bootable_usb.sh
Last active September 27, 2020 17:35
How to create a bootable USB image on Mac
# first, format USB as ExtFAT (using Disk Utility)
# convert .iso to .img
hdiutil convert -format UDRW -o ./ubuntu-18.04.2-server-amd64.img ubuntu-18.04.2-server-amd64.iso
# mac adds .dmg at the end, we need to remove that
mv ubuntu-18.04.2-server-amd64.img.dmg ubuntu-18.04.2-server-amd64.img
# find out the disk-name:
diskutil list
@schneefisch
schneefisch / links.md
Last active September 14, 2020 09:08
Link-list for development
@schneefisch
schneefisch / update_deployments.sh
Last active September 14, 2020 09:08
Update deployments in kubernetes
# How to do updates to your environment
# more details to deployments and scaling:
# https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
# 1. update the deployment.yml file and run
kubectl apply -f <deployment.yml>
# 2. update an image:
kubectl set image <deployment/nginx-deployment> <nginx>=<nginx:1.9.1>
@schneefisch
schneefisch / kubernetes_secrets.sh
Last active September 14, 2020 09:08
Basics for kubernetes-secrets
# Secrets handling
# create secret
kubectl create secret generic db-user-pass --from-file=./username.txt --from-file=./password.txt
# get Secrets
kubectl get secrets
# get secret details
kubectl get secret mysecret -o yaml
# encode secret values
echo "asdfghjkl==" | base64 --decode
@schneefisch
schneefisch / scale_deployment.sh
Last active September 14, 2020 09:09
scale deployment replicas in kubernetes
# scale to 10 replicas
kubectl scale deployment <nginx-deployment> --replicas=10
# auto-Scaling
kubectl autoscale deployment <nginx-deployment> --min=2 --max=8 --cpu-percent=80
@schneefisch
schneefisch / kubectl_basics.sh
Last active September 22, 2023 06:32
Basics for kubectl
# Documentation: https://kubernetes.io/docs
#
# get kubernetes version and info
kubectl version
# get infor on pods
kubectl get pods
# get info on deployments
kubectl get deployments
kubectl describe deployments