Shell Cheat Sheet
Filtrage reseau
capture trafic
tcpdump -n icmp
tcpdump -i eth0
#Log dans un pcap
tcpdump -w 0001.pcap -i eth0
#Ecoute d'une interface
tcpdump -n -i eth0
#specifie un filtre
tcpdump -i eth0 port 22
tcpdump -i eth0 src 192.168.0.2
tcpdump -i eth0 dst 50.116.66.139
pfSence: tcpdump -v -nni em0 host 195.116.131.76 and port 500
Connaitre tout les ports écouté par la machine
netstat -paunt
VI
suppressions mode INSERTION dans VI
:set mouse-=a
Or in /etc/vim/vimrc add: let g:skip_defaults_vim = 1
SSH
Clef public:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDqgdKE7erz7FzB9ZAQFYUahFVFFoUnbmvUXiR5nK2OWbiWZh8QB4uPACIVNCllsBmaFSC44puVJGlAeHPSByZN/zAKsuPLHfdTvovcz0+jBZP/oexb/78GMVoV4S1zZMZzAzUSMOAcSSIATVOS5hha6DHq7VJOTFA3ReqexOKgdEC6GzkUKuiof0AhkE0JxObZQzH6PohqDPTIuGPtQHeM1vytPq4XI5tPTRO8oMJS8Oaj3HwVhbD9lDBvM/05tZ8ZHeS7zMOzCgdyTR3qD5mdJCuie+7hb1+/DXZ8vnGA3VaRlj5ANBs1elX6b/3RytbgL0lkwKKtHZz8cDIHfJwOe1Izh1HR+lJDhFtqtGKB85oeZRqwmQWIHJFcYJqSO+deC8n3CaF9uKGJd7wMVR9ULTOunLx8j7y8ueO5KXLKvvtcAPf+u4QvbuF1COaK2D8PhrlUCqWZ6JXeUNTUWnKfPnxsXNpEYugThAas5rAkQsAJg9gpkOa1b4ZHm+dx+5V2JBXHyVpx86E+mz7D3iIajj+4+Yu3HEzovsM8PjRBjcRv3x8zw6t5rEpFSjrwHEjsn9+bEfHzyGAc3HbJ3w4ngvIjQLzTN4oHz2bGMHxUHIklTHMeKPYKtMRdjXfnlA6Ly+/l0TScH8MQAYmkXIBdkfClkuEj+IYV8/kRcM8bYw== guillaume@moulard.org4096.id_rsa.pub
# creation d'une clef valable 180 jours :
ssh-keygen -t rsa -b 4096 -f gaym6331.gitlabDiod.key.id-rsa
# signature d'une clef public valable 1 an
ssh-keygen -s ca.key -n test -I 1 -V +365d guillaume.key.pub
# regenere une clefs publique a partire d'une clef privé
ssh-keygen -y -f ~/.ssh/identity
# regenere la signature
ssh-keygen -l -f ~/.ssh/identity
# use ca.key in sshd
echo "TrustedUserCAKeys /etc/ssh/ca.key.pub" >> /etc/ssh/sshd_config
tartget:
sudo useradd test
sudo mkdir /home/test
sudo chown test:test /home/test
ssh-copy-id -i guillaume.key.pub test@127.0.0.1
ssh test@127.0.1 -i guillaume.key
bash
#!/bin/bash
#
# description:
# V0 : D/M/20 By guillaume@moulard.org - creation
#set -x
if [ $# -ne 1 ]; then
echo call: $0 VIPNAME
exit 1
fi
# see man test pour tout les -eq -ne -lt -le -gt -ge possible
#voir aussi man bash
if [ $? -eq 0 ]; then
echo GOOD
else
echo BAD
fi
tableaux
TAB=()
TAB[1]="ps -ef"
TAB[2]=${TAB[1]:4:3}
Command
for i in $(seq 0 ${#TAB[@]}); do
echo TAB[i]
done
or
for i in ../epita/ING1/s5/project/moular_b-myfind/src/*
or
for i m1 m2 ; do
case $1 in
"GQR") TLD=omrq ; N=qpr-sd-prxgin ;;
"GQN") TLD=omnq ; N=qpn-sd-prxgin ;;
*) echo bad parameter :GQR, GQN ; exit 1 ;;
esac
for name [ [ in [ word ... ] ] ; ] do list ; done
for (( expr1 ; expr2 ; expr3 )) ; do list ; done
select name [ in word ] ; do list ; done
case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac
if list; then list; [ elif list; then list; ] ... [ else list; ] fi
while list-1; do list-2; done
# exemple
rep=gm
while [[ 'gm' == $ret ]]; do
rep=GG
done
until list-1; do list-2; done
function
testfunct () {
#$1=A
echo testOneVIP $1, $2
}
testfunct A B
bkp (){ cp -a $1 $1-bkp$(date +"%y%m%d%H%M%S") ; }
t20 (){ for x in {01..20}; do $@ ; done }
AnsibleDuPauvre
export TF="192.27.114.85 192.25.114.69 192.27.114.90 192.25.114.74"
export CMD="sudo hostname"
lanceTF() { for VM in $TF ; do ssh $VM "$CMD" ; done }
lanceTF
Git
export https_proxy=http://http-proxy-gin:3128
git clone https://....
git add <File to update>
testIP.sh
git commit -m "teste alias"
git push
gp(){ git add -A ;
git commit -m \"`[[ -z "$1" ]] && echo "Dev/Debug/Typo"\" || echo $1`\" ;
git push ;
git pull ;
}
UML, Markdown and notes
plant Uml : https://plantuml.com/
etherpad : https://etherpad.net/p/guillaumeMoulard https://pi.moulard.org/etherpad/p/guillaume.moulard
Use and test: https://pi.moulard.org/ethe/EtherPlant/src/index.html?https://pi.moulard.org/etherpad/p/useCase
slides : https://pi.moulard.org/ethe/EtheRemark/src/index.html?https://pi.moulard.org/etherpad/p/slide
Editeur MarkDown en ligne: https://hackmd.io/
droit linuX
Valeur Droits Signification
0 - - - Aucun droit
1 - - x Exécutable
2 - w - Ecriture
3 - w x Ecrire et exécuter
4 r - - Lire
5 r - x Lire et exécuter
6 r w - Lire et écrire
7 r w x Lire écrire et exécuter