Skip to content

Instantly share code, notes, and snippets.

@lemajes
lemajes / SALTSTACK-101.md
Last active July 20, 2023 13:05
[SALTSTACK 101] SALTSTACK 101 #linux #saltstack #salt-minion #salt-master #reactor #pillar #formula

SALTSTACK 101

  • Setup minion conf
# /etc/salt/minion
master: xxx.xxx.xxx.xxx
master_port: 4506
@lemajes
lemajes / htaccess-redirections.md
Created July 7, 2023 14:38
Common Htaccess redirections #php #htaccess #redirection #rewrite #url

Redirect if !_DEBUG=1

RewriteCond %{QUERY_STRING} !_DEBUG=1 #RewriteRule ^/(.)$ /$1?_DEBUG=1 [QSA,R,L] RewriteRule ^/(.)$ /$1?_DEBUG=1 [QSA,L]

#301 Redirects for .htaccess

#Redirect a single page: Redirect 301 /pagename.php http://www.domain.com/pagename.html

@lemajes
lemajes / MySQL_mydumper_myloader.md
Last active July 12, 2023 13:15
[MySQL mydumper/myloader] MySQL mydumper/myloader #bash #mysql #mydumper #myloader #backup #restore
  • Backup mydumper -B my_db -l 60 -o my_backup_temp_folder

  • Restore #-d for backup folder, -B for destination database, -t for threads count, -o for overwriting tables myloader -d ./ -B my_db -t 2 -o

  • Manually import massive datas without blocking

mysql -u root -p
set global net_buffer_length=1000000; # Set network buffer length to a large byte number
@lemajes
lemajes / S3-OBJECT-STORAGE-OVH.md
Created July 7, 2023 13:39
[S3 OBJECT STORAGE OVH] S3 Object Storage OVH #ovh #s3 #object #storage #filesystem #s3fs

S3 OBJECT STORAGE OVH

To mount it, Object storage must use s3 API (and not Openstack Swift) => need to associate user to bucket

  • Put crentials in file /root/.passwd-s3fs keeeeeeeeeeeeeeyy:seeeeeecreeeetkey

  • Perms chmod 600 /root/.passwd-s3fs

@lemajes
lemajes / HAPROXY-101.md
Last active July 13, 2023 15:38
[HAPROXY 101] Haproxy 101 #haproxy #debian #101

HAPROXY 101

  • Stop sending requests to node to enable maintenance on it echo "set server backend_name/svc_name state drain" | socat stdio /var/run/haproxy/admin.sock

  • Start sending requests to node to disable maintenance on it echo "set server backend_name/svc_name state ready" | socat stdio /var/run/haproxy/admin.sock

  • Show statistics

@lemajes
lemajes / CLONEZILLA-101.md
Created June 7, 2023 16:54
[CLONEZILLA 101] Clonezilla 101 #clonezilla #101 #debian

CLONEZILLA 101

  • Extract and mount image
gunzip -d image.gz
mount -o loop image.img /mnt -t ntfs -o ro
@lemajes
lemajes / SYSPREP-101.md
Created June 5, 2023 08:57
[SYSPREP 101] Sysprep 101 #sysprep #101 #windows #prepare #cloning

SYSPREP 101

Prepare system

  • Run sysprep %WINDIR%\system32\sysprep\sysprep.exe /generalize /shutdown /oobe

  • Run sysprep for converting physical machine to vm %WINDIR%\system32\sysprep\sysprep.exe /generalize /shutdown /oobe /mode:vm

@lemajes
lemajes / haproxy.conf
Last active June 14, 2023 14:02 — forked from phobos182/haproxy.conf
[LogStash Configuration for HAProxy] Logstash configuration for Haproxy #logstash #haproxy
input {
syslog {
type => "haproxy-access"
port => 514
}
}
filter {
grok {
type => "haproxy-access"
@lemajes
lemajes / OVH-VPS-101.md
Last active May 22, 2023 22:12
[OVH VPS 101] OVH VPS 101 #ovh #vps #101 #dd #backup #restore

OVH VPS 101

  • Backup from rescue to ssh remote using dd from backup server ssh [email protected] "dd if=/dev/sdb | gzip" > /tmp/disk-image.raw.gz

  • Unzip on backup server gunzip -d /tmp/disk-image.raw.gz

  • Restore from ssh remote using dd from target

@lemajes
lemajes / elastalert-101.md
Last active May 22, 2023 16:57
[Elastalert 101] Elastalert 101 #elastalert #101

Elastalert 101

  • Test configuration elastalert --config /opt/elastalert/config.yaml --rule sql_injection_attempt --verbose