Skip to main content

Primary links

  • Home
  • AI
  • Kubernetes
  • Incus
  • Ansible
  • Terraform
  • OpenStack
  • Virtualization
  • Linux
  • SmartHome
  • HowTo

Misc

  • Linux
  • Hardware
  • Programming
  • Databases
  • Multimedia
  • Windows

Cloud

  • OpenStack
  • cloud-config
  • nextcloud

Virtualization

  • Virtualization
  • Incus
  • Docker
  • KVM
  • Kubernetes
  • LXC
  • LXD
  • QEMU
  • VMware
  • VirtualBox
  • multipass
  • podman
  • vagrant
  • XEN

Network

  • DNS
  • Firewall
  • Linux
  • OpenvSwitch
  • SSL
  • VLAN
  • VPN
  • iPXE
  • namespaces
  • nmcli
  • tcpdump

Storage

  • CEPH
  • DRBD
  • LVM
  • S3
  • ZFS
  • btrfs

Automation / CI/CD

  • Install
  • Ansible
  • GitLab
  • LLM
  • Preseed
  • Puppet
  • Terraform
  • Ubuntu autoinstall

Monitoring / Visualisation

  • Grafana
  • Icinga
  • Prometheus
  • Monitoring
  • ELK
  • mermaid

Configure proxy

export http_proxy=http://10.203.0.1:5187/
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
export PROXY_SERVER=192.168.0.222
export PROXY_USER=foo
export PROXY_PASS=bar

cat <> /etc/environment
export http_proxy="http://${PROXY_USER}:${PROXY_PASS}@${PROXY_SERVER}:8080"
export https_proxy="http://${PROXY_USER}:${PROXY_PASS}@${PROXY_SERVER}:8080"
export no_proxy="localhost,127.0.0.1,foo.example.com"
EOF

cat < /etc/apt/apt.conf.d/12proxy
Acquire::http::Proxy "http://${PROXY_USER}:${PROXY_PASS}@${PROXY_SERVER}:8080";
Acquire::https::Proxy "http://${PROXY_USER}:${PROXY_PASS}@${PROXY_SERVER}:8080";
EOF

Set http_proxy with special characters in password
https://www.cyberciti.biz/faq/unix-linux-export-variable-http_proxy-with-special-characters/
https://www.fourmilab.ch/webtools/unum/

#wget https://www.fourmilab.ch/webtools/unum/download/unum.tar.gz
#tar xzf unum.tar.gz
#./unum.pl 'F@o:o!B#ar$'

MY_NEW_PASS='F@o:o!B#ar$' 
echo ${MY_NEW_PASS}| uni2ascii -qp | sed 's/0x00/%/g'

sudo vi /etc/environment

#Replace with:
#F%40o%3Ao%21B%23ar%24

Socks

Install prometheus under Ubuntu

Install from repository

sudo apt-get install -y prometheus
# optional
sudo apt-get install -y prometheus-node-exporter
sudo apt-get install -y prometheus-alertmanager
sudo apt-get install -y prometheus-pushgateway

Ansible installation

https://github.com/panticz/ansible/tree/master/roles/prometheus
- hosts: localhost
  roles:
    - prometheus

Login
http://SERVER_IP:9090/

Commands

avg_over_time(node_memory_MemAvailable[5m])/1024/1024

Repositroy
https://github.com/cloudalchemy/ansible-prometheus

Docker

docker run --name prometheus -d -p 127.0.0.1:9090:9090 quay.io/prometheus/prometheus

Ports
https://github.com/prometheus/prometheus/wiki/Default-port-allocations

API
http://SERVER_IP:9090/metrics

Query

node_disk_io_now{device="sda"}

Deploy node_exporter without installation

# https://prometheus.io/download/#node_exporter
wget https://github.com/prometheus/node_exporter/releases/download/v0.16.0/node_exporter-0.16.0.linux-amd64.tar.gz -qO /tmp/node_exporter.tar.gz
tar xzf /tmp/node_exporter.tar.gz -C /tmp/
mv /tmp/node_exporter-0.16.0.linux-amd64/node_exporter /usr/bin/prometheus-node-exporter
nohup /usr/bin/prometheus-node-exporter &
prometheus-node-exporter --version

node_exporter Ansible installation

https://github.com/panticz/ansible/tree/master/roles/prometheus-node-exporter
- hosts: localhost
  roles:
    - prometheus-node-exporter

Use SSH tunnel to access node_exporter metrics
https://mkezz.wordpress.com/2017/08/04/prometheus-in-docker-ssh-tunnel-to-target-nodes/

Alerting
http://prometheus.example.com:9093/

Linux Lite

Download
https://www.linuxliteos.com/download.php

LXC: create Ubuntu Bionic container

sudo lxc-create -t ubuntu -n bionic -- template-options -r bionic

Nginx access control / GeoIP

cat < /etc/nginx/conf.d/geoip.conf 
geoip_country /usr/share/GeoIP/GeoIP.dat;

map $geoip_country_code $allowed_country {
    default no;
    DE yes;
    CH yes;
}

log_format allow "allow $remote_addr;";
EOF
chmod 644 /etc/nginx/conf.d/geoip.conf


cat < /usr/local/bin/nginx-allow
#!/bin/bash

while inotifywait --quiet --event create,delete --exclude "[^c][^o][^n][^f]$" /tmp
do
    /usr/sbin/nginx -t && /usr/sbin/service nginx reload
done
EOF
chmod 755 /usr/local/bin/nginx-allow


cat < /etc/systemd/system/nginx-allow.service
[Unit]
Description=Nginx configuration monitor service
After=nginx.service

[Service]
Type=simple
ExecStart=/usr/local/bin/nginx-allow
Restart=on-abort

[Install]
WantedBy=multi-user.target
EOF
chmod 644 /etc/systemd/system/nginx-allow.service


systemctl daemon-reload
systemctl enable nginx-allow.service 
systemctl start nginx-allow.service 



cat < /etc/cron.hourly/clean_nginx_allow
#!/bin/bash

find /tmp -ctime +2 -name nginx_allow_*.conf -delete
EOF


cat /etc/nginx/sites-available/nginx-allow
...
set $backend $scheme://10.0.10.101;
error_page 403 =404 /404.gif;

location /nginx-allow/ {
    if ($allowed_country = yes) {
        access_log /tmp/nginx_allow_$remote_addr.conf allow;
        proxy_pass $backend;
    }

    proxy_pass $backend/404.html;
}

location ~ ^(/wp-admin|/admin) {
    include /tmp/nginx_allow_*.conf;
    deny all;

    proxy_pass $backend;
}
...

cat < /root/bin/nginx_allow_ddns.sh
#!/bin/bash -e

DDNS=foo.dyndns.com

sleep 3

IP=$(getent hosts ${DDNS} | cut -d" " -f1)
[ -n ${IP} ] && echo "allow ${IP};" > /tmp/nginx_allow_${IP}.conf

service nginx reload
EOF

# crontab -e
@reboot /root/bin/nginx_allow_ddns.sh

Links
https://docs.nginx.com/nginx/admin-guide/mail-proxy/mail-proxy/
https://docs.nginx.com/nginx/admin-guide/security-controls/controlling-access-by-geoip/

VMware Player

[embed_url: https://raw.githubusercontent.com/panticz/installit/master/install.vmware-player.sh]

sudo apt-get install -y open-vm-tools

Links
https://docs.vmware.com/en/VMware-Workstation-Player/12.0/com.vmware.player.linux.using.doc/GUID-42F4754B-7547-4A4D-AC08-353D321A051B.html

openconnect

echo pass1234 | openconnect --no-cert-check vpn.example.com --user foo

start-stop-daemon --start --make-pidfile --pidfile "${VPNPID}" \
            --stderr "${VPNERRFILE}" --stdout "${VPNLOGFILE}" \
            --background --exec /bin/bash \
            -- -c "exec /usr/sbin/openconnect --pid-file=\"${VPNPID}\" ${!VPNOPTS} ${!SERVER} <<< \`echo \"${!PASSWORD}\"\`"

# Custom script
# cat /etc/vpnc/post-connect.d/route 
#!/bin/bash

ip route del default
ip route add default via 10.0.17.254
ip route add 120.1.0.0/16 dev tun0 scope link

SNMP: Linux software RAID state

Compile snmp-swraid

LTSP Webcam

export LTSP_HANDLE_DAEMONS=false

ltsp-chroot -p -a amd64 /bin/bash

apt-get install -y guvcview

echo 'KERNEL=="video*", GROUP="video", MODE="0666"' > /etc/udev/rules.d/99-webcam.rules

ltsp-update-image

Links
https://wiki.ubuntuusers.de/Archiv/LTSP/Lokale_Webcam_nutzen/

rsync

On-the-fly backup (backup a running system)

sudo rsync -e "ssh -i ${HOME}/.ssh/id_rsa" \
  -av \
  --delete \
  --numeric-ids \
  --exclude=proc/* \
  --exclude=sys/* \
  --exclude=tmp/* \
  root@${HOST}:/ .

limit bandwith to 2 mbit/s

rsync --bwlimit=2000 --delete -avz root@www.example.com:/ /media/backup/www.example.com/$(date -I)/

# Specify SSH key and configuration
sudo rsync -av \
    -e "ssh -i /home/foo/.ssh/id_rsa -F /home/foo/.ssh/config" \
    --delete \
    --numeric-ids \
    -av \
    /from/dir/ root@192.168.0.1:/to/dir

--ignore-times

Set owner and permissions

rsync -og --chown=nobody:nogroup --chmod=644 file.txt root@example.com:/dir/file.txt

Rsync files betwen two remote hosts withoud direct connection

HOST_FROM=www.example.com
HOST_TO=new.example.com
DIR_FROM=/var/www/html/
DIR_TO=/var/www/html/
ssh -A -R localhost:50000:${HOST_TO}:22 ${HOST_FROM} "rsync -e 'ssh -o StrictHostKeyChecking=no -p 50000' --delete -a ${DIR_FROM} localhost:${DIR_TO}"

Delete files after successfully copy

sshpass -p "${SSH_PASS}"\
  rsync -av --remove-source-files -e ssh ${SSH_USER}@${SSH_HOST}:~/htdocs/*.gz /mnt/backup/

rsync --remove-source-files -av /source/dir/ 192.168.1.1:/target/dir/
rsync -aHAXx --numeric-ids --delete --stats --info=progress2 --out-format="[%%t]:%%o:%%f:Last Modified %%M" --verbose -e "ssh -o

Set file permissions

rsync --chmod=400 _.file1.pem root@www.example.com:/etc/haproxy/ssl/

Pagination

  • Previous page
  • 5
  • Next page
linux
Profiles GitHub StackOverflow LinkedIn Xing
Contact Imprint
© panticz 2026

Cookie-Einstellungen

Diese Website nutzt eingebettete Inhalte von Drittanbietern (z.B. YouTube, SoundCloud). Beim Laden dieser Inhalte werden Daten an die jeweiligen Anbieter übermittelt. Datenverarbeitungserklärung