Table des matières
- 2026:
- 2025:
4 billet(s) pour septembre 2026
| Notes HTTP Strict Transport Security - HSTS | 2026/09/18 11:04 | Jean-Baptiste |
| Notes GNU Linux GPU carte graphiques | 2026/09/08 15:49 | Jean-Baptiste |
| Notes GNU Linux graphique | 2026/09/08 15:42 | Jean-Baptiste |
| Notes urlencoding - passer des mots de passe en HTTPS | 2026/09/03 17:58 | Jean-Baptiste |
Voir :
man sudo_root
Voir aussi :
- OpenDoas
- runuser / setpriv (util-linux)
- sudoreplay
- sux (su X11)
- userhelper
systemd-run -t bashousystemd-run --shell- Pourquoi ne pas utiliser sudo dans un contener : https://docsaid.org/en/blog/gosu-usage/
Notes sudo et sudoers
sudo does fork+exec instead of just exec
visudo
jean ALL=(test) NOPASSWD: ALL
Utilisation
sudo -u test -s /bin/bash echo 'ls /root/' | sudo -H -S -n bash
Test sudoers
sudo -l sudo -U username -l sudo -U username -ll
env_keep : Check environment variables sudo preserved :
sudo sudo -V
Restricting a sudo command to specific arguments
user ALL=(root) NOPASSWD: /usr/bin/systemctl (stop|start|restart) (httpd|mysql)
Prohibiting Command Arguments with sudo Follow the program name with the single argument “” in /etc/sudoers:
smith ALL = (root) /usr/local/bin/mycommand ""
Exemple de Sudoers
Accès root sans mdp pour un utilisateur
# export EDITOR=vim visudo -f /etc/sudoers.d/admin
/etc/sudoers.d/admin
jean ALL=(ALL) NOPASSWD: ALL
# # Disable "ssh hostname sudo <cmd>", because it will show the password in clear. # You have to run "ssh -t hostname sudo <cmd>". # Defaults requiretty Host_Alias LOCAL_SERVER=servername Cmnd_Alias CHK_MSG=/usr/local/bin/check_msg.sh Defaults:nagios !requiretty nagios LOCAL_SERVER=(ALL) NOPASSWD: CHK_MSG
operator ALL=(root) sudoedit /home/*/*/test.txt
user1 ALL = NOPASSWD: /bin/ln -s /dev/ttyACM[1-9] /dev/ttyS[1-9] user1 ALL = NOPASSWD: /usr/bin/unlink /dev/ttyS[1-9]
Faire des groupes
sudo visudo -f /etc/sudoers.d/networking
Cmnd_Alias CAPTURE = /usr/sbin/tcpdump Cmnd_Alias SERVERS = /usr/sbin/apache2ctl, /usr/bin/htpasswd Cmnd_Alias NETALL = CAPTURE, SERVERS %netadmin ALL=NETALL
Demander le mot de passe du compte root au lieu de l'utilisateur
Defaults rootpwc
Demander le mot de passe x fois
Defaults passwd_tries=4
Timeout
Defaults timestamp_timeout=x Defaults:peter timestamp_timeout=5
Logs
Defaults logfile=/var/log/sudo.log
Mails
#Defaults mail_always Defaults mail_badpass Defaults mailto="<email@example.com>"
PATH
/etc/sudoers
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
Exemples sudoers
Exemple sudoedit
/etc/sudoers.d/sudoedit
exploit ALL=(root) NOPASSWD: sudoedit /var/log/*log exploit ALL=(root) NOPASSWD: sudoedit /var/log/*.log.1 exploit ALL=(root) NOPASSWD: sudoedit /var/log/*err exploit ALL=(root) NOPASSWD: sudoedit /var/log/*.gz
export EDITOR=vim sudoedit /var/log/message.log sudo -e /var/log/message.log
Alias
Cmnd_Alias ADMIN=/usr/bin/atop, /usr/bin/qps jean ALL= NOPASSWD: ADMIN
Voir Sudo: You're Doing it Wrong
Defaults insults # Users Hosts = (Runas) Cmds # %Group Hosts = (Runas) Cmds %wheel ALL=(ALL) ALL Defaults env_keep+="HOME SSH_CLIENT SSH_CONNECTION SSH_TTY SSH_AUTH_SOCK" mwlucas dns1=ALL mwlucas,pkdick dns1,dns2 = \ /sbin/service names,/sbin/service syslogd mwlucas db1 = (oracle) ALL mwlucas dns[1-4]=ALL mwlucas ALL = /usr/local/sbin/* mwlucas ALL=/opt/bin/program -[acQ] # "" disallow arguments mwlucas ALL=/opt/bin/program "" Cmnd_Alias BACKUP = /sbin/dump,/sbin/restore,/usr/bin/mt mwlucas ALL=BACKUP User_Alias ADMIN_USERS = sysops,admin,sysadm User_Alias TAPEMONKEYS_USERS = mwlucas, jeanmm Host_Alias WWW = web1,web2,web3 TAPEMONKEYS_USERS WWW=BACKUP Runas_Alias DB_RUNAS = oracle, pqsql, mysql fred DB_HOSTS = (DB_RUNAS) ALL DBA_USERS DB_HOSTS = (DB_RUNAS) ALL mwlucas ALL = NOEXEC: ALL Defaults!ALL NOEXEC Cmnd_Alias MAYEXEC = /bin/newaliases, /sbin/fdisk mwlucas ALL = ALL, EXEC: MAYEXEC mwlucas ALL = sudoedit /etc/rc.conf
identifiant ALL = (ALL) /chemin/complet/commande, NOPASSWD: /chemin/complet/autrecommande
Toutes les commandes situées à la droite du mot-clé NOPASSWD: peuvent être exécutées par l'utilisateur ou le groupe d'utilisateurs précisé en début d'instruction. Celles restées à sa gauche sont toujours soumises à l'authentification par mot de passe.
User_Alias USER_T_PLOP_ALL=user1 USER_T_PLOP_ALL= (jean) EXEC: NOPASSWD: ALL #Runas_Alias=oracle, orainst, mysql, myinst
Checksum
Using openssl, to generate the checksum:
openssl dgst -sha224 /usr/local/sbin/mycommand
SHA224(/usr/local/sbin/mycommand)= 52246fd78f692554c9f6be9c8ea001c9131c3426c27c88dbbad08365
Then in your sudoers file (on the same line):
www-data ALL=(ALL) NOPASSWD:
sha224:52246fd78f692554c9f6be9c8ea001c9131c3426c27c88dbbad08365
/usr/local/sbin/mycommand
Exemple sudo
Get shell
sudo -u jean -i sudo -u jean -s sudo -u jean -s /bin/bash sudo su - jean
PAM
Source : https://www.tecmint.com/switch-user-account-without-password/
Permette aux membres du groupe postgres d'impersonifier l'utilisateur postgres /etc/pam.d/su
auth [success=ignore default=1] pam_succeed_if.so user = postgres auth sufficient pam_succeed_if.so use_uid user ingroup postgres
In the above configuration, the first line checks if the target user is postgres, if it is, the service checks the current user, otherwise, the default=1 line is skipped and the normal authentication steps are executed.
Équivalent à
%postgres ALL=NOPASSWD: /bin/su – postgres
Autres
Ausible - become
Voir :
$ ansible-doc -t become ansible.builtin.sudo ... become_flags default: -H -S -n ...
gosu, setpriv, su-exec, setuser (Python)
Voir :
Dans un container doit être appelé exec exec. Exemple :
exec gosu myAppUser /usr/local/bin/myApp --foo=bar
Exemples :
gosu user-spec command [args] gosu tianon bash gosu nobody:root bash -c 'whoami && id' gosu 1000:1 id
su-exec apache:1000 /usr/sbin/httpd -f /opt/www/httpd.conf
Notes stockage
- SDS (Software-Defined Storage)
- pNFS
- NFSv4.1
- Lustre
- GlusterFS
- Ceph
- ZFS
- DRBD
- Tahoe LAFS
- Btrfs
- LVM
Voir :
- les backends rclone
- Longhorn / OpenEBS (Container Attached Storage CAS) / CubeFS
- Ksync (pour dev)
BTRFS \ Red Hat will not be moving Btrfs to a fully supported feature. It was fully removed in Red Hat Enterprise Linux 8. \ Voir Stratis
ZFS
zpool list <plop>
NAS
- TrueNAS (FreeNAS)
- OpenMediaVault
Notes stockage CEPH
Voir :
Voir aussi :
- SeaweedFS
- JuiceFS
ceph status ceph-deploy admin serveur
===== 30 TB 30 TB 30 TB
90 TB
DFS 100 TB SMB Windows DFS
Lexique
OSD (pour Object Storage Daemon), un disque
Etapes : Monter un CEPH Monter un Samba DFS Droits lectures pour tout auth Synchro les données
U:\Services\Direction des Etudes Gty\Modification\Inventaire DE-SdT\Inventaire 2020
http://people.redhat.com/bhubbard/nature/nature-new/glossary/#term-node
Prérequis
Matériel Voir : https://docs.ceph.com/en/latest/start/hardware-recommendations/
Logiciel ; http://people.redhat.com/bhubbard/nature/nature-new/start/quick-start-preflight/
Liste :
- Réseau (Ceph préconise l’utilisation de 2 interfaces réseau)
- /etc/hosts
- NTP
- Ceph deploy user (with passwordless sudo privileges)
- SSH passwordless
- Sudo tty (Si
requiretty⇒Defaults:ceph !requiretty) - SELinux
Composants
MDS (Meta Data Server)
Consomme du CPU et de la RAM (1 Gi de mémoire par instance). Utile que si l'on planifie d'utiliser CephFS.
Monitors
For small clusters, 1-2 GB is generally sufficient
OSD (Object Storage Daemon)
Du côté de la mémoire, 512 Mi par instance sont suffisants sauf lors de la récupération où 1 Gi de mémoire par Ti de données et par instance est conseillé.
Installation
Voir :
Les users CEPH ne doivent pas être des utilisateurs standard, mais des utilisateurs de services eux même chargés d’une gestion fine des droits Ceph préconise l’utilisation de 2 interfaces réseau
echo "deb http://ftp.debian.org/debian buster-backports main" >> /etc/apt/sources.list.d/backports.list apt-get update apt-get install -t buster-backports ceph
zcat /usr/share/doc/ceph/sample.ceph.conf.gz > /etc/ceph/ceph.conf
# uuidgen 67274814-239f-4a05-8415-ed04df45876c
/etc/ceph/ceph.conf
[global] ### http://docs.ceph.com/docs/master/rados/configuration/general-config-ref/ fsid = 67274814-239f-4a05-8415-ed04df45876c # use `uuidgen` to generate your own UUID public network = 192.168.56.0/24 cluster network = 192.168.56.0/24 # Replication level, number of data copies. # Type: 32-bit Integer # (Default: 3) osd pool default size = 2 ## Replication level in degraded state, less than 'osd pool default size' value. # Sets the minimum number of written replicas for objects in the # pool in order to acknowledge a write operation to the client. If # minimum is not met, Ceph will not acknowledge the write to the # client. This setting ensures a minimum number of replicas when # operating in degraded mode. # Type: 32-bit Integer # (Default: 0), which means no particular minimum. If 0, minimum is size - (size / 2). ;osd pool default min size = 2 osd pool default min size = 1 [mon] ### http://docs.ceph.com/docs/master/rados/configuration/mon-config-ref/ ### http://docs.ceph.com/docs/master/rados/configuration/mon-osd-interaction/ # The IDs of initial monitors in a cluster during startup. # If specified, Ceph requires an odd number of monitors to form an # initial quorum (e.g., 3). # Type: String # (Default: None) mon initial members = kub1,kub2,kub3 [mon.kub1] host = kub1 mon addr = 192.168.56.21:6789 [mon.kub2] host = kub2 mon addr = 192.168.56.22:6789 [mon.kub3] host = kub3 mon addr = 192.168.56.23:6789
ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow'
/etc/ceph/ceph.client.admin.keyring
[client.admin] key = AQBGuWRfchSlDRAA3/bTmiPTLLN0w4JdVOxpDQ== caps mds = "allow" caps mon = "allow *" caps osd = "allow *"
ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *' ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *' ceph-authtool --create-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring --gen-key -n client.bootstrap-osd --cap mon 'profile bootstrap-osd' --cap mgr 'allow r'
systemctl enable ceph.target systemctl start ceph.target systemctl enable ceph-mon@$(hostname -s) systemctl start ceph-mon@$(hostname -s) systemctl status ceph-mon@$(hostname -s).service
# ceph health detail
HEALTH_WARN 3 monitors have not enabled msgr2
MON_MSGR2_NOT_ENABLED 3 monitors have not enabled msgr2
mon.kub1 is not bound to a msgr2 port, only v1:192.168.56.21:6789/0
mon.kub2 is not bound to a msgr2 port, only v1:192.168.56.22:6789/0
mon.kub3 is not bound to a msgr2 port, only v1:192.168.56.23:6789/0
# ceph mon enable-msgr2
# ceph health detail
HEALTH_OK
OSD
Voir : https://wiki.nix-pro.com/view/CEPH_deployment_guide
ceph-volume remplace ceph-disk
ceph-volume inventory ceph-volume inventory /dev/sdb ceph-volume lvm batch --bluestore /dev/sda /dev/sdb /dev/sdc CEPH_VOLUME_DEBUG=1 ceph-volume inventory /dev/sdb ceph-volume lvm zap /dev/sdb --destroy
ceph-osd -i 0 --mkfs --mkkey --osd-uuid 13b2da5a-033f-4d58-b106-2f0212df6438 chown -R ceph:ceph /var/lib/ceph ceph auth list ceph auth add osd.0 osd 'allow *' mon 'allow profile osd' -i /var/lib/ceph/osd/ceph-0/keyring
/var/lib/ceph/osd/ceph-0/keyring
[osd.0] key = AQBizGxGhJcwJxAAHhOGHXQuCUTktxNszj62aQ==
ceph --cluster ceph osd crush add-bucket kub1 host ceph osd crush move kub1 root=default chown -R ceph:ceph /var/lib/ceph ceph --cluster ceph osd crush add osd.0 1.0 host=kub1 ceph-volume raw prepare --bluestore --data /dev/sdb1 systemctl start ceph-osd@1
CephFS
cd /etc/ceph sudo mkcephfs -a -c /etc/ceph/ceph.conf -k ceph.keyring
Administration
Ceph health
ceph -s ceph mon_status -f json-pretty ceph -w ceph df ceph health detail ceph -n client.admin --keyring=/etc/ceph/ceph.client.admin.keyring health ceph pg dump ceph pg X.Y query ceph pgdump_stuck inactive
OSD
ceph osd tree watch ceph osd pool stats ceph osd map
Suppression OSD
ceph osd crush reweight osd.XX 0. # Passage du poids de l’OSD à 0 ceph osd out XX # Marquage de l’OSD comme non disponible au cluster # 1er mouvement de données, ~10To rebalancés #stop ceph-osd id=XX systemctl stop ceph-osd@XX.service # arrêt de l'exécution de l’OSD sur le serveur ceph osd crush remove osd.XX # Sortie logique de l’OSD du cluster # 2nd mouvement de données (non prévu), ~10To rebalancés ceph auth del osd.{osd-num} # suppression des clés d’authentification de l’OSD au cluster ceph osd rm {osd-num} # suppression définitive de l’OSD du cluster #ceph-volume lvm zap /dev/sdb --destroy
Autres
ceph mgr module l
ceph mgr module enable plop
Client
Voir :
mount -t ceph 128.114.86.4:6789:/ /mnt/pulpos -o name=admin,secretfile=/etc/ceph/admin.secret
/etc/fstab
128.114.86.4:6789,128.114.86.5:6789,128.114.86.2:6789:/ /mnt/pulpos ceph name=admin,secretfile=/etc/ceph/admin.secret,noatime,_netdev 0 2
ceph-fuse -m 128.114.86.4:6789 /mnt/pulpos
Notes stéganographie et WaterMarking
FS
# apt-cache search watermarking mat - Metadata anonymisation toolkit snowdrop - plain text watermarking and watermark recovery
Forensic
Voir :: sleuthkit / mmls / img_stat
Notes cgroup
Voir :
Tester si tous est ok
apt-get install lxc
lxc-checkconfig
ou
#apt-get install docker.io #/usr/share/docker.io/contrib/check-config.sh
https://github.com/opencontainers/runc/blob/main/script/check-config.sh
Dans Debian :mount cgroup automatically in mountkernfs.
Normalement sous Debian, les cgroup sont automatiquement montés (dans le mountkernfs)
$ mount | grep cgroup none on /sys/fs/cgroup type tmpfs (rw,relatime,size=4k,mode=755) systemd on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,name=systemd)
Si ce n'est pas le cas, la technique d'ajouter dans /etc/fstab
/etc/fstab
cgroup /cgroup cgroup defaults 0 0
ou alors passer à systemd
apt-get install systemd systemd-sysv
Voir :
Mais comme nous choisissons la méthode avec des services (méthode à la Redhat)
Pour connaître les ?????
prit en charge par le noyau
# lssubsys -a cpuset cpu cpuacct memory devices freezer net_cls blkio perf_event
Install du packet
apt-get update && apt-get install -y cgroup-tools
Puis
dpkg -L cgroup-tools
Donc
mkdir /etc/sysconfig/ cp -p /usr/share/doc/cgroup-tools/examples/cgconfig.sysconfig /etc/sysconfig/cgconfig cp -p /usr/share/doc/cgroup-tools/examples/cgred.conf /etc/sysconfig/cgred cp -p /usr/share/doc/cgroup-tools/examples/cgred /etc/init.d/ cp -p /usr/share/doc/cgroup-tools/examples/cgconfig /etc/init.d/ cp -p /usr/share/doc/cgroup-tools/examples/cgconfig.conf /etc/ cp -p /usr/share/doc/cgroup-tools/examples/cgrules.conf /etc/ chmod a+x /etc/init.d/cgconfig /etc/init.d/cgred ln -s /etc/sysconfig/cgconfig /etc/default/ ln -s /etc/sysconfig/cgred /etc/default/ sed -i -e 's|/var/lock/subsys/|/var/lock/|g' /etc/init.d/cgred sed -i -e 's|/var/lock/subsys/|/var/lock/|g' /etc/init.d/cgconfig getent group cgred >/dev/null || groupadd -r cgred
Puis prendre le fichier /etc/rc.d/init.d/functions sur une CentOS.
mkdir -p /etc/rc.d/init.d/ cp -p functions /etc/rc.d/init.d/
Commenter la ligne [ -z “${CONSOLETYPE:-}” ] && CONSOLETYPE=“$(/sbin/consoletype)“
vi /etc/rc.d/init.d/functions
Puis
mkdir /cgroup cd /cgroup mkdir $(lssubsys -a)
Erreur sous Debian :
# /etc/init.d/cgconfig start Starting cgconfig service: Error: cannot mount memory to /cgroup/memory: No such file or directory /usr/sbin/cgconfigparser; error loading /etc/cgconfig.conf: Cgroup mounting failed [FAIL] Failed to parse /etc/cgconfig.conf ... failed!
Solution : rajouter “cgroup_enable=memory swapaccount=1” à votre Grub :
/etc/default/grub
GRUB_CMDLINE_LINUX="vga=795 cgroup_enable=memory swapaccount=1"
update-grub
Pour le debug si nécessaire :
export CGROUP_LOGLEVEL=debug
Autres
allocated 133693440 bytes of page_cgroup please try 'cgroup_disable=memory' option if you don't want memory cgroups
/etc/fstab
cgroup /sys/fs/cgroup cgroup defaults 0 0
/etc/default/grub
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
sudo apt-get install cgroup-tools sudo cgcreate -a jean -g memory:plop echo 10000000 > /sys/fs/cgroup/memory/plop/memory.kmem.limit_in_bytes sudo cgexec -g memory:plop bash
cgroupv1 ou v2 ?
podman info docker info mount | grep cgroup2 systemctl --user status grep cgroup /proc/filesystems
Pour passer à la version 2
grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=1"
Autres
cat /sys/fs/cgroup/user.slice/user-1003.slice/cgroup.controllers cpuset cpu io memory pids
