Table des matières
0 billet(s) pour février 2026
Monter une partition d un disque qui a été cloné entièrement via dd ou ddrescue
Méthode 1 - kpartx
$ kpartx -av disk.img loop3p1 : 0 20964762 /dev/loop3 63
Pour vérifier la partition:
fsck /dev/mapper/loop3p1
Pour supprimer le périphérique
kpartx -d disk.img
Méthode 2 - losetup offset
Source : Mounting a raw partition file made with dd or dd_rescue in Linux
dd if=/dev/sda of=/mnt/nfs/backup/harddrive.img
file harddrive.img
harddrive.img: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, stage2 address 0x2000, stage2 segment 0x200, GRUB version 0.97; partition 1: ID=0x83, active, starthead 1, startsector 63, 33640047 sectors, code offset 0x48
startsector 63
Voir gdisk et parted pour GPT. A tester
fdisk -l harddrive.img
Device Boot Start End Blocks Id System harddrive.img * 63 33640109 16820023+ 83 Linux
63 x 512 = 32256
Pour monter la partition en lecture
mount -o ro,loop,offset=32256 harddrive.img /mnt/loop
Pour faire un fsck ou un mkfs
losetup --offset 32256 /dev/loop2 harddrive.img fsck /dev/loop2
Puis pour monter la partition
mount /dev/loop2 /mnt/loop
Monter un serveur SFTP chroote avec OpenSSH
Voir : https://michauko.org/blog/sftp-chroot-et-pas-de-ssh-bloquer-un-utilisateur-dans-un-repertoire-1099/
Voir aussi :
mkdir -p /chroot/shared/ chown root:nsc /chroot chmod 750 /chroot useradd sftpuser -M -d /dev/null -s /sbin/nologin # useradd is a low level utility for adding users. On Debian, administrators should usually use adduser(8) instead. echo "/mnt/shared/ /chroot/shared/ none _netdev,bind 0 0" >> /etc/fstab
- /etc/ssh/sshd_config
# Subsystem sftp /usr/lib/openssh/sftp-server Subsystem sftp internal-sftp Match User sftpuser ChrootDirectory /chroot ForceCommand internal-sftp AllowTcpForwarding no GatewayPorts no X11Forwarding no PermitTunnel no AllowAgentForwarding no PermitTTY no
mount /chroot/shared/ systemctl restart sshd systemctl status sshd
Autres
The simplest way is to create some script that would take care of that. Add
Match User test1 ForceCommand /path/to/your/script.sh
And your script will basically run whatever the user wants, unless it is request for SFTP:
#!/bin/bash if [[ "$SSH_ORIGINAL_COMMAND" =~ .*sftp-server.* ]]; then echo "SFTP not allowed" exit 255; else exec "$SSH_ORIGINAL_COMMAND" fi
Monter un partage ftp comme une partition
Obsolète
Voir Notes rclone
sudo apt-get update sudo apt-get install curlftpfs
mkdir -p ~/mnt/ftp curlftpfs ftp://ftp.truc.org ~/mnt/ftp/ -o user=utilisateur:pass fusermount -u ~/mnt/ftp/
Voir ~/.netrc
Monitoring procedure Centreon SNMP RedHat
Prerequisites
This chapter describes the prerequisites installation needed by plugins to run. Centreon Plugin
Install this plugin on each needed poller:
yum install centreon-plugin-Operatingsystems-Linux-Snmp
Prerequistes concerns a RHEL like distribution, you may need to adapt it if you run an other Linux distro.
Be sure to have with you the following information:
- Read-Only SNMP community
- IP Address of the monitoring server
Install the SNMP service
With the root user, install the following package and its dependencies:
yum install net-snmp
Configure SNMP on your server
Open the file /etc/snmp/snmpd.conf with your favorite text editor Modify the following lines (Replace the <SNMPCOMMUNITY>):
- /etc/snmp/snmpd.conf #com2sec notConfigUser default <SNMPCOMMUNITY
com2sec notConfigUser default public
Comment all the lines which begin by view:
- /etc/snmp/snmpd.conf
view systemview included .1.3.6.1.2 view systemview included .1.3.6.1.2.1.25
Just after the previous lines, add the following line:
- /etc/snmp/snmpd.conf
view systemview included .1
save the file
start the snmp service:
service snmpd start
Add SNMP to booting services:
chkconfig --add snmpd; chkconfig --level 2345 snmpd on
Check your SNMP installation
snmpwalk -v 1 -c <SNMPCOMMUNITY> <IPSERVER> .1.3.6.1.2.1.1.1
You should get a response looking like the following:
SNMPv2-MIB::sysDescr.0 = STRING: Linux <SERVER> 2.6.18-128.1.10.el5 #1 SMP Thu May 7 10:39:21 EDT 2009 i686
SNMP Permissions
You need a SNMP read access on following OIDs:
HOST-RESOURCES-MIB: .1.3.6.1.2.1.25 (cpu, uptime, storage, process) UCD-SNMP-MIB: .1.3.6.1.4.1.2021 (swap, memory, inodes, diskio) IF-MIB: .1.3.6.1.2.1.2 (traffic)
Troubleshooting
Read Troubleshooting SNMP
Créer un proxy inverse sed
Voir également netsed
Intro
Lors d'une mission, un collègue a trouvé cette astuce.
Créer un reverse proxy et ext_filter Ce module permet de modifier les flux sortant. La page officiele est : http://httpd.apache.org/docs/2.2/mod/mod_ext_filter.html
Il faut activer le module et desactiver le deflate (pour que la sortie de soit pas compressé).
a2enmod ext_filter a2dismod deflate
On définit la commande:
ExtFilterDefine fixtext mode=output intype=text/xml cmd="/bin/sed s/toto/titi/g"
Que l'on utilise après (dans la sous section Location) : SetOutputFilter fixtext
NetSed
Le serveur écoute sur le port TCP 8080. Nous créons un nouveau socket écoutant sur 8084
netsed tcp 8084 127.0.0.1 8080 s/andrew/mike%00%00 s/andrew/mike%00%00 >/dev/null
