Table des matières
3 billet(s) pour janvier 2026
| Notes rsh rcp | 2026/01/21 18:08 | Jean-Baptiste |
| Git - Duplication d'un dépôt | 2026/01/19 10:22 | Jean-Baptiste |
| Exemple simple de conf Nagios | 2026/01/14 10:07 | Jean-Baptiste |
Notes OpenBSD
Installation de paquets (Git, vim...)
export PKG_PATH=ftp://ftp.fr.openbsd.org/pub/OpenBSD/5.6/packages/amd64/
Mise à jour
pkg_add -Uu
NTP temps horloge heure
Temps horloge Comment vérifier que NTP fonctionne
Voir :
- Si pb de flux réseau voir tunnel_ssh_udp_forward
- /etc/adjtime
man 5 adjtime_config man 4 rtc(Real-Time Clock)
Configurer
Configurer via Systemd
/etc/systemd/timesyncd.conf
[Time] Servers=0.debian.pool.ntp.org 1.debian.pool.ntp.org
timedatectl set-ntp true
Diag
systemctl restart systemd-timesyncd systemctl status systemd-timesyncd
Configurer via Chrony
TODO
Configurer via NTP
aptitude install ntp
On configure le serveur de temps via le fichier
Notamment les lignes suivantes:
/etc/ntp.conf
# le serveur doit lui aussi se synchroniser server 0.fr.pool.ntp.org # ou debian.pool.ntp.org server 1.fr.pool.ntp.org # ou debian.pool.ntp.org server 2.fr.pool.ntp.org # ou debian.pool.ntp.org server 3.fr.pool.ntp.org # ou debian.pool.ntp.org # Autoriser les autres ordinateurs à ce connecter: restrict 0.0.0.0 mask 0.0.0.0 # Limiter les ordinateurs pouvant se connecter à notre réseau personnel: broadcast 192.168.0.255
The systems were using only two NTP servers
Four NTP servers are recommended. See http://support.ntp.org/bin/view/Support/SelectingOffsiteNTPServers
“With two, it is impossible to tell which one is better, because you don't have any other references to compare them with. This is actually the worst possible configuration -- you'd be better off using just one upstream time server and letting the clocks run free if that upstream were to die or become unreachable.”
“Use at least 4 NTP servers”
Pour éviter la dérive sur les VM
Ou passer à Chrony
tinker panic 0
“The tinker panic value of 0 tells NTP that no matter what the time offset is, not to panic and exit. This is recommended for virtual machines because virtual machines have no physical clock and can be paused at anytime and started back up hours later.”
Source : https://www.redhat.com/en/blog/avoiding-clock-drift-vms
Voir :
1 - Add the following line to the beginning of the /etc/ntp.conf file
tinker panic 0
2 - Remove or comment the “driftfile”
#driftfile /var/lib/ntp/drift/ntp.drift # path for drift file
3 - Restart the ntpd.service
/bin/systemctl restart ntpd.service
Voir https://www.suse.com/fr-fr/support/kb/doc/?id=000021102
Configurer via ntpdate
ntpdate -B ajustement progressif
ntpdate -b ajustement brutal
aptitude install ntpdate
Utilisation manuel
/usr/sbin/ntpdate -dvu 192.168.2.11
Automatisation
crontab -e
Ajouter la ligne suivante:
0 3 * * * root /usr/sbin/ntpdate -dv ntp.serveur.org > /dev/null
Tester / simuler / lecture seul / dry-run
ntpdate -q pool.ntp.org
Autres
/etc/sysconfig/ntp
SYNC_HWCLOCK=yes
This is an option to ntpdate
Horloge matérielle / BIOS / hwclock
Afficher la date et l’heure
date
Si la date est incorrecte, utiliser date MMDDmm
Afficher l’heure du BIOS
hwclock
Commande pour que le BIOS puisse utiliser l’heure du système
hwclock --systohc --utc
Comparaison du temps système et le BIOS
date
hwclock
Vérification dans le fichier /etc/sysconfig/clock
UTC=true
Vérifier
Source: https://www.cyberciti.biz/faq/linux-unix-bsd-is-ntp-client-working/
Commandes pour vérifier
- ntpq – standard NTP query program
- ntpstat – show network time synchronisation status
- timedatectl – show or set info about ntp using systemd
- chronyc tracking
ntpstat
ntpstat
| Exit status | Error |
|---|---|
| 0 | Clock is synchronised. |
| 1 | Clock is not synchronised. |
| 2 | If clock state is indeterminant, for example if ntpd is not contactable |
ntpq
ntpq -pn
# ntpq -p remote refid st t when poll reach delay offset jitter =========================================== europium.canoni 193.79.237.14 2 u 15 64 1 28.682 -3.649 0.015 horlogegps.rese 10.3.128.189 2 u 14 64 1 29.002 -11.238 0.015 kontir.mkc.fr 213.251.128.249 2 u 13 64 1 76.501 18.866 0.015 dnscache-london 140.203.16.5 2 u 12 64 1 58.209 4.266 0.015
Une fois la synchronisation faite des , + et - apparaissent devant les noms de serveur. Le serveur précédé d’une astérisque () est celui utilisé, ceux précédés d’un moins (-) sont actuellement éliminés par l’algorithme de choix des serveurs, ceux précédés d’un plus (+) sont des candidats potentiels à la synchronisation et ceux précédés d’un espace sont soit inaccessibles, soit trop éloignés.
Une synchronisation correcte implique une valeur de « delay » et de « offset » non nulle, et de « jitter » inférieure à 100
Resynchroniser
sudo service ntp stop sudo ntpd -gq sudo service ntp start
SystemD - timedatectl
timedatectl status |grep NTP
NTP enabled: yes NTP synchronized: yes
Chrony - chronyc
chronyc tracking chronyc sources chronyc sourcestats
Autres
Timesyncd
/lib/systemd/system/systemd-timesyncd.service.d/wsl.conf
# Enable timesyncd on WSL machines # so WSL clock is synced on resume from suspend of the host. [Unit] ConditionVirtualization= ConditionVirtualization=|!container ConditionVirtualization=|wsl
Adjtimex
apt-get install adjtimex
Avant de faire une manip
adjtimex -u -l=/var/log/clocks.log
clocksource
Oracle recommande de changer le “clock source” à tsc pour les VM Linux x86-64.
# cat /sys/devices/system/clocksource/clocksource0/available_clocksource xen tsc acpi_pm
If the tsc clock source is available, then set tsc as the current clock source.
echo "tsc" > /sys/devices/system/clocksource/clocksource0/current_clocksource
Using any text editor, append the clocksource directive to the GRUB_CMDLINE_LINUX line in the /etc/default/grub file to retain this clock source setting even after a reboot.
/etc/default/grub
GRUB_CMDLINE_LINUX="rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off transparent_hugepage=never clocksource=tsc"
Falsifier la date et l'heure avec faketime
faketime 2016-01-01 gpg --list-keys
Pb
Pb fichier de conf ignoré à cause d'une conf via DHCP
Voir aussi : https://coreos.com/os/docs/latest/configuring-date-and-timezone.html
/var/lib/ntp/ntp.conf.dhcp
ps -ef |grep ntp
ntp 9777 1 0 08:04 ? 00:00:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /var/lib/ntp/ntp.conf.dhcp -u 108:113
rm /var/lib/ntp/ntp.conf.dhcp systemctl restart ntp
ou sur Redhat
rm /var/lib/dhclient/chrony.servers.eth0 systemctl restart chronyd.service
Pb - the NTP socket is in use, exiting
Solution 1
ntpdate -u pool.ntp.org
Solution 2
Arrêt du service (pour libérer le socket réseau UDP) puis
ntpdate -u pool.ntp.org
http://superuser.com/questions/639202/updating-time-ntpdate3108-the-ntp-socket-is-in-use-exiting ntptrace
Pb avec VirtualBox
ConditionFileIsExecutable=!/usr/sbin/VBoxService was not met
# systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/systemd-timesyncd.service.d
└─disable-with-time-daemon.conf
Active: inactive (dead)
Condition: start condition failed at Fri 2019-10-11 11:37:16 CEST; 5min ago
└─ ConditionFileIsExecutable=!/usr/sbin/VBoxService was not met
Docs: man:systemd-timesyncd.service(8)
Solution
/lib/systemd/system/systemd-timesyncd.service.d/disable-with-time-daemon.conf
[Unit] # do not run timesyncd if we have another NTP daemon installed #ConditionFileIsExecutable=!/usr/sbin/VBoxService
systemctl daemon-reload systemctl restart systemd-timesyncd
Nouvelle install Debian et configuration KDE
Applications que j'utilise sous KDE4 (Debian Jessie) :
système :
htop
gnome-disk-utility
synaptic
Pour que l'option filtre rapide de Synaptic s'affiche, il faut installer le paquet "apt-xapian-index".
Détail du paquet dans Debian :
Ce paquet fournit update-apt-xapian-index, un outil pour maintenir un index Xapian sur les informations de paquets Debian dans /var/lib/apt-xapian-index, et axi-cache, un outil en ligne de commande qui utilise cet index.
axi-cache permet de rechercher dans les paquets très rapidement, et s'interface de façon intelligente avec le complètement de la ligne de commande, en fournissant des mots-clés à partir du contexte et des suggestions d'étiquettes avant même que la commande de recherche ne soit lancée.
update-apt-xapian-index permet à des greffons d'être installés dans /usr/share/apt-xapian-index pour indexer toutes sortes d'informations comme les étiquettes Debtags, les informations de popularité des paquets (« popcon »), les notes des paquets et tout ce qui pourrait correspondre.
L'index généré par update-apt-xapian-index est autodocumenté via un fichier README créé automatiquement avec des informations sur la structure de l'index et toutes les données qui peuvent être trouvées.
Le "filtre rapide" sera présent une fois l'indexation terminée. Cela ne prend que quelques minutes.
luckybackup
bleachbit
gtkorphan
localepurge
preload
prelink
firmware-linux-free
firmware-linux-nonfree
hddtemp
configurer :
$ sudo dpkg-reconfigure hddtemp
lmsensors
configurer :
$ sudo sensors-detect
Ensuite inscrire oui à toutes les questions, puis redémarrer l'ordinateur.
Conky-std
redshift
redshift-plasmoïd
multimédia :
smplayer
smtube
amarok
kradio
qarte
phonon-backend-gstreamer
graphisme :
mypaint
kcolorchooser
digikam
internet :
rekonq
qupzilla
iceweasel
Bureautique :
kontact
qstardict
goldenstardict
Application très intéressante, plusieurs dictionnaires sont directement installable via les dépôts de Debian. Pas besoin de les chercher sur le net.
Thème :
oxygen-transparent
kwin-style-oxygen-transparent
kde-style-oxygen-transparent
gtk2-engines-oxygen
Paquet qui permet aux applications gtk2 de se fondre dans le décor.
gtk3-engines-oxygen
Paquet qui permet aux applications gtk2 de se fondre dans le décor.
Thème KDE pour les applications GTK :
Gnome-disk-utility :
Pour avoir tous les icones correspondant à l'application installée : gnome-icon-theme gnome-icon-theme-symbolic pour kde.
$ apt-get install gnome-icon-theme gnome-icon-theme-symbolic
Synaptic :
Pour que Synaptic ait le thème kde, plutôt que le thème gnome.
$ cp ~/.config/gtk-2.0 ~/root/.config/gtk-2.0
$ cp ~/.config/gtk-3.0 ~/root/.config/gtk-3.0
Autre thème KDE :
Thème oxygen transparent :
Avec les dépôts experimental, possibilité d'installer un thème oxygen transparent :
$ apt-get install kde-style-oxygen-transparent kwin-style-oxygen-transparent oxygen-transparent
On peut configurer le niveau de transparence via la configuration du système.
Systemd :
Mettre /var/tmp, /tmp, dans la ram, empêche le démarrage via systemd.
Nouvelle Install Debian configuration optimisation
Optimisation perf : https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.2/html/Performance_Tuning_Guide/system-tuning.html
Lors d'une nouvelle install, il faut d'assurer de bien aligner les partions Voir : formater_une_carte_microsd_en_optimisant_les_performances_et_la_duree_de_vie
/etc/apt/apt.conf.d/00InstallRecommends
APT::Install-Recommends "false";
/etc/ssh/sshd_config
PermitRootLogin without-password
mount |grep -v noatime |grep ext4 | grep -v noatime
Voir debian_noatime
SystemD - Désactiver le redémarrage par défaut si ctrl+alt+del
unlink /lib/systemd/system/ctrl-alt-del.target ln -s /dev/null /lib/systemd/system/ctrl-alt-del.target systemctl daemon-reload
- Si x86 (32 bits)
Dans Debian, la configuration noyau 686 a été remplacée par la configuration 686-pae qui utilise PAE (« Physical Address Extension » − Extension d'adresse physique). Si le serveur utilise la configuration 686 mais n'a pas la PAE, il faut utiliser la configuration 486 à la place. On peut vérifier si le serveur a la PAE en lançant grep -q '^flags.*\bpae\b' /proc/cpuinfo && echo oui || echo non S'il ne l'a pas (c'est-à-dire que la commande précédente renvoie non), il faut installer linux-image-486 puis supprimer linux-image-686 et/ou linux-image-2.6-686 s'ils sont actuellement installés.
- Hardening
Table ARP en dur ? notes_arp
/etc/security/limits.d/90-nproc.conf
# Default limit for number of user's processes to prevent # accidental fork bombs. # See rhbz #432903 for reasoning. * soft nproc 1024 root soft nproc unlimited www-data soft nproc unlimited
apt-get install debian-security-support
check-support-status
service nfs-common stop service portmap stop service rpcbind stop apt-get -y autoremove --purge portmap rpcbind
umask pam
https://www.maketecheasier.com/hardening-ubuntu-server/
apt-get install fail2ban rsyslog
pas de connexion avec utilisateur root (sauf par clef)
/etc/issue.net
-----------------------------------------------------------------------------
ATTENTION : Ne vous connectez pas a cette machine sans y etre autorise.
Toute tentative de piratage sera suivie d'une plainte aupres
des autorites. Le CERT sera egalement prevenu.
WARNING : Don't try to connect without permission. Every illegal access will
be referred to the appropriate authorities and the CERT.
-----------------------------------------------------------------------------
/etc/ssh/sshd_config
PasswordAuthentication no Port <PORT> AllowUsers <USER> Banner /etc/issue.net PermitRootLogin without-password
Ne pas oublier de configurer fail2ban après le changement de port SSH et de redémarrer le service
- Crontab que pour root
echo root > /etc/cron.allow
Standart atop munin sysstat
Machine physique lm-sensors smartmontools
amd64-microcode intel-microcode
Microcode Intel Linux Processor Microcode Data File
Config : /etc/default/smartmontools
start_smartd=yes
service smartmontools restart
sensors-detect --auto
VM
Redirection de la console
Si plusieurs CPUs
irqbalance Et numad ?
getconf _NPROCESSORS_ONLN irqbalance
/etc/default/irqbalance
TODO comparer avec
mpstat -P ALL 60
Si Ordinateur de bureau
Pas décidé :
Activation dépôt multimédia http://www.deb-multimedia.org/
apt-get install libdvdcss2
/etc/default/grub
GRUB_CMDLINE_LINUX="vga=795"
ou vga=788
Puis
Déprécié, utiliser à la place :
gfxpayload=1024x768x16,1024x768
update-grub
Décidé
#apt-get install rtmpdump # Remplacé par curl ? apt-get install mplayer2 vlc cclive
#update-alternatives --set x-terminal-emulator /usr/bin/lxterminal
Preload va examiner vos habitudes et pré-charger en mémoire les librairies les plus souvent sollicitées.
apt-get install preload
Prelink. Permet de charger en mémoire les bibliothèques partagées
apt-get install prelink
icedove bleachbit
/etc/inputrc
set bell-style none
apt-get install libnotify-bin
apt-get install numlockx
numlockx on
a vérif
grep -q numlockx /etc/rc.local ||sed -i -e 's/^exit 0/numlockx on\n&/' /etc/rc.local
Conky
voir ~/.conkyrc
~/.config/autostart/conky.desktop
#!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Type=Application Terminal=false Exec=conky Name=Conky
Faire le ménage dans /etc/xdg/autostart/*.desktop
Exemple
rm /etc/xdg/autostart/caribou-autostart.desktop rm /etc/xdg/autostart/evolution-alarm-notify.desktop rm /home/jibe/.config/autostart/vino-server.desktop rm /home/jibe/.config/autostart/gnome-user-share.desktop
- Aleger
Accélérer Xfce4. Ne pas afficher les images dans les menus, texte seul. Cacher le contenu des fenêtres lors des déplacements, redimensionnements.
Remplacement de bash par dash dpkg-reconfigure dash
Installer slim comme gestionnaire de session graphique.
apt-get install slim
/etc/sysctl.d/swappiness.conf
vm.swappiness=10 vm.vfs_cache_pressure=50
/etc/fstab
tmpfs /media/virtuelram tmpfs defaults,noatime,nodiratime,size=2500M 0 0
Voir /etc/default/tmpfs
Nettoyer /tmp
/lib/systemd/system/systemd-tmpfiles-clean.timer
[Unit] Description=Daily Cleanup of Temporary Directories Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8) [Timer] OnBootSec=15min OnUnitActiveSec=1d
/lib/systemd/system/systemd-tmpfiles-clean.service
[Unit] Description=Cleanup of Temporary Directories Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8) DefaultDependencies=no Conflicts=shutdown.target After=systemd-readahead-collect.service systemd-readahead-replay.service local-fs.target time-sync.target Before=shutdown.target [Service] Type=oneshot ExecStart=/usr/bin/systemd-tmpfiles --clean IOSchedulingClass=idle
/etc/tmpfiles.d/tmp.conf
# Clear tmp directories separately, to make them easier to override d /tmp 1777 root root 10d d /var/tmp 1777 root root 30d # Exclude namespace mountpoints created with PrivateTmp=yes x /tmp/systemd-private-%b-* X /tmp/systemd-private-%b-*/tmp x /var/tmp/systemd-private-%b-* X /var/tmp/systemd-private-%b-*/tmp
Diminuez le nombre de bureaux virtuels
Un “MTA” (Mail Transfert Agent) est installé par défaut et lancé au démarrage, exim est utile comme serveur de courriels, mais également pour recevoir les courriels du système. Si vous voulez simplement recevoir les courriels systèmes, mais sans avoir le démon exim lancé en permanence, changez l'option de configuration “QUEUERUNNER=” dans /etc/default/exim4 de la manière suivante :
/etc/default/exim4
QUEUERUNNER='nodaemon'
- Tous
Commande checkrestart (pour savoir les services / processus à redémarrer après mise à jour)
apt-get install debian-goodies
Tous !?
#echo "*.* /dev/tty12" >> /etc/rsyslog.conf echo "*.* -/dev/tty12" >/etc/rsyslog.d/tty12.conf
Tous !?
/etc/default/grub
GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
update-grub
apt-get install sed vim build-essential python-minimal # Pour Ansible
/etc/sysctl.d/swappiness.conf
vm.swappiness=5
sysctl -p /etc/sysctl.d/swappiness.conf
~/.bashrc
export LS_OPTIONS='--color=auto' eval "`dircolors`" alias ls='ls $LS_OPTIONS' alias ll='ls $LS_OPTIONS -l' alias l='ls $LS_OPTIONS -lA' alias rm='rm -i' alias cp='cp -i' alias mv='mv -i'
- # Juste après install
sed -i -e 's/^deb cdrom/#deb cdrom/' /etc/apt/sources.list update-alternatives --set editor /usr/bin/vim.basic
- Par encore décidé
/etc/default/exim4
#QUEUERUNNER='combined' QUEUERUNNER='nodaemon'
/etc/vim/vimrc.local
syntax on
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
if has("autocmd")
filetype plugin indent on
endif
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set smartcase " Do smart case matching
set incsearch " Incremental search
set hidden " Hide buffers when they are abandoned
Autre
Activer le cache disque avec gnome-disk-utility ou hdparm !?
Pas de login si /home/$USER absent
Cloud AWS
Source : https://wiki.debian.org/Cloud/SystemsComparison
vm.swappiness = 0 vm.dirty_ratio = 80 vm.dirty_background_ratio = 5 vm.dirty_expire_centisecs = 12000 net.core.somaxconn = 1000 net.core.netdev_max_backlog = 5000 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_wmem = 4096 12582912 16777216 net.ipv4.tcp_rmem = 4096 12582912 16777216 net.ipv4.tcp_max_syn_backlog = 8096 net.ipv4.tcp_slow_start_after_idle = 0 net.ipv4.tcp_tw_reuse = 1 net.ipv4.ip_local_port_range = 10240 65535 kernel.sysrq = 0
net.core.somaxconn
Notification à la perte de l'alimentation - Enable power failure notification
Voir :
~/bin/powerlost-notify.sh
#! /bin/bash export DISPLAY=:0 USER_TMP=jean PID_TMP=$(pgrep -o -u $USER_TMP lxqt-session) OPTS="env $(xargs --null --max-args=1 echo < /proc/${PID_TMP}/environ |grep ^DBUS_SESSION_BUS_ADDRESS=)" acpi -a |grep -q off-line && \ sudo -u $USER_TMP $OPTS notify-send -i /usr/share/icons/oxygen/base/48x48/status/battery-charging-caution.png -u critical "Power Lost" ""
crontab -e
# m h dom mon dow command * * * * * $HOME/bin/powerlost-notify.sh
