thorko.deLinux / Unix systems administrator

Latest SysadminDB entries


Debian - WLAN automatically connect to different networks

install wpasupplicant resolvconf

~$ apt-get install wpasupplicant resolvconf

create your /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant
network={
ssid="h_da"
scan_ssid=1
key_mgmt=WPA-EAP IEEE8021X
auth_alg=OPEN
eap=TLS
phase1="peaplabel=0"
phase2="auth=MSCHAPV2"
pairwise=CCMP
identity="<your username>"
password="<your password>"
eap=PEAP
id_str="h_da"
}
network={
ssid="no_internet"
scan_ssid=1
proto=WPA RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk=<your psk>
id_str="no_internet"
}
network={
ssid="DENIC"
scan_ssid=1
proto=WPA RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk=
id_str="denic"
}

create your psk with

~$ wpa_passphrase ssid [passphrase]

your id_str you will need in /etc/network/interfaces

create your /etc/network/interfaces

source-directory /etc/network/interfaces.d
auto lo
allow-hotplug eth0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
iface eth0 inet dhcp
iface h_da inet static
address 172.16.204.235
netmask 255.255.252.0
gateway 172.16.207.254
dns-nameservers 141.100.56.53 141.100.10.110 8.8.4.4
dns-search fbi.h-da.de
iface denic inet dhcp
iface no_internet inet static
address 192.168.0.15
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 4.2.2.2 156.154.70.1 208.67.222.222
dns-search thorko.local

Now you can start your wlan interface with ifup

Make sure your wpasupplicant gets started at boot time

~$ systemctl enable wpa_supplicant



SSH - store passwords in kwallet

~$ apt-get install sshpass ksshaskpass

vim ~/.bashrc

function sshp { 
sshpass -p "$(ksshaskpass "ssh $*")" ssh "$@"
}



KDE automatically add ssh-key to ssh-agent

create your ssh-key

~$ ssh-keygen -t rsa

 

enable ssh-agent to run on KDE login

~$ vim /etc/X11/Xsessions.options
allow-failsafe
allow-user-resources
allow-user-xsession
use-ssh-agent
use-session-dbus

create script to add ssh-key

~$ vim /usr/local/bin/ssh-agent.sh
#!/bin/bash
export SSH_ASKPASS=/usr/bin/ksshaskpass
/usr/bin/ssh-add < /dev/null
~$ chmod a+x /usr/local/bin/ssh-agent.sh

link this script to autostart-scripts

ln -s /usr/local/bin/ssh-agent.sh ~/.config/autostart-scripts/ssh-agent.sh
~$ vim ~/.kde/env/ssh-agent.sh
#!/bin/bash
eval $(ssh-agent)
~$ chmod a+x ~/.kde/env/ssh-agent.sh

 

create a script to stop ssh-agent when you log out from KDE

~$ vim ~/.kde/shutdown/ssh-agent.sh
#!/bin/bash
ssh-agent -k
~$ chmod a+x ~/.kde/env/ssh-agent.sh



MySQL - truncate all tables of database

echo "set foreign_key_checks=0;" >> /tmp/truncate.sql
mysql -Nse "show tables" <database> | while read table; do echo "truncate table $table;" >> /tmp/truncate.sql; done
echo "set foreign_key_checks=1;" >> /tmp/truncate.sql
mysql -u root <database> < /tmp/truncate.sql



Zabbix - Triggers stuck on dashboard

If there are triggers schown on dashboard which are nowhere else seen in Zabbix you can release them if you set the value in database to 0.

Get the triggerid with this query

mysql> SELECT t.triggerid,t.expression,t.description,t.url,t.priority,t.lastchange,t.comments,t.error,t.state FROM triggers t \
WHERE NOT EXISTS (SELECT NULL FROM functions f,items i,hosts h WHERE t.triggerid=f.triggerid AND f.itemid=i.itemid \
AND i.hostid=h.hostid AND (i.status<>0 OR h.status<>0)) \
AND t.status=0 AND NOT EXISTS (SELECT NULL FROM functions f,items i,hosts h WHERE t.triggerid=f.triggerid \
AND f.itemid=i.itemid AND i.hostid=h.hostid AND h.maintenance_status=1)\
AND t.priority IN ('0','2','3','4','5') AND t.value='1' AND t.flags IN ('0','4')\
ORDER BY t.lastchange DESC LIMIT 100 OFFSET 0;

update these triggers

mysql> update triggers set value=0 where triggerid = '<your triggerid>';



(c) 2014 by thorko.de