Memento shell

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

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

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 AAAAB3NzaC1yc2EAAAADAQABAAACAQCcpjw5M39Z9kwjg/LTjR2/P68/hbSdxG/zd/zRyn0SuOU7POvkQcvV6xHMBajOzvcMlXtFqkP+8TtOgqxgz6A4m1y5/KuLJOn19CylOKvOsEnql+LjbosK7MGsuONhX5rQTN65sRcfLABlpChZ23CD1Vl+pHO7fQ4txwqLtHjbmMiv7wZPfcCrevDvIpYB0DQXdCQFjGLcNgLX9HqXV+aWy8IbzRmkXeES200d95qeVb/SUf2hzlPPAwiP8V/zXVoNwUOXDSUHPyJEho9a+ffP6n/b6bLmUkudbBvwATMLT+oefg/M4XloHrNfLAm7KfGIDiV8YhLZVu/KI6Kg2mlFKtqnmhPi1CZaC6VRNoKsUSTxdadcR3oxOCf1Y/u4HxjC26SDX2ycNZtUV3CEmETh91liZ8OLrIbwhP6DLCvtPRdKn9mlVQ0930y7Jt0quSvFiB5oX15nz+dSKoryCKdTsYoQc5EDcW0cztJTZNRFBKNBJDaRUd3BdpBFw2vigSLJTTeQCSEn6rQ1IEqAmPhpkESxbXhE/kCfw8ehASNC1eoCPKzy5fiztgqH+LSm25JWML5DHEOEgBvoQkiloSRXpmFEFqY4+AQsAJWbnz/dhk/pXb6G5MFIGp00oRWBFgFoxkkv6trK9xu+notXzDtt6rUzxq1txEDy5bL4TfMrSQ== guillaume@moulard.org



referer to : https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/sec-creating_ssh_ca_certificate_signing-keys

https://blog.orouet.fr/?p=143



# creation d'une clef :

ssh-keygen -t rsa -b 4096 -f guillaume.key

# 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


# 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



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 "Tipo"\" || echo $1`\" ;

git push ;

git pull ;

}


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