Difference between revisions of "Chroot Debian users"
Line 29: | Line 29: | ||
<span data-link_translate_en_title="Chroot Debian users" data-link_translate_en_url="Chroot+Debian+users"></span>[[:en:Chroot Debian users]][[en:Chroot Debian users]] | <span data-link_translate_en_title="Chroot Debian users" data-link_translate_en_url="Chroot+Debian+users"></span>[[:en:Chroot Debian users]][[en:Chroot Debian users]] | ||
{{#seo: | {{#seo: | ||
− | |title= | + | |title=Chroot Debian users |
|title_mode=append | |title_mode=append | ||
|keywords=these,are,your,keywords | |keywords=these,are,your,keywords | ||
− | |description= | + | |description=Discover in this article how to chroot Debian users |
|image=Uploaded_file.png | |image=Uploaded_file.png | ||
|image_alt=Wiki Logo | |image_alt=Wiki Logo |
Revision as of 13:48, 16 December 2020
fr:Chrooter ses utilisateurs Debian
en:Chroot Debian users
es:Usuarios de Debian chroot
pt:Usuários Debian chroot
it:Utenti Debian chroot
nl:Chroot Debian gebruikers
de:Debian-Chroot-Benutzer
zh:Chroot Debian 用户
ar:مستخدمي ديبيان استجذار
ja:Chroot Debian ユーザ
pl:Użytkownicy Debiana chroot
ru:Пользователи Debian chroot
ro:Utilizatorii Debian chroot
he:משתמשי דביאן Chroot
This article has been created by an automatic translation software. You can view the article source here.
fr:Chrooter ses utilisateurs Debian
he:משתמשי דביאן Chroot
ru:Пользователи Debian chroot
ja:Chroot Debian ユーザ
ar:مستخدمي ديبيان استجذار
zh:Chroot Debian 用户
ro:Utilizatorii Debian chroot
pl:Użytkownicy Debiana chroot
de:Debian-Chroot-Benutzer
nl:Chroot Debian gebruikers
it:Utenti Debian chroot
pt:Usuários Debian chroot
es:Usuarios de Debian chroot
en:Chroot Debian users
Introduction
Il peut être utile de chrooter ses utilisateurs afin de limiter leur liberté de mouvements au sein de son système.
Sur un Server de production, pensez à effectuer ces opérations pendant les heures creuses afin de minimiser l'impact de vos actions.
Prerequisites
One of the prerequisites essential is to keep its system as up-to-date as possible.
apt-get update apt-get upgrade
In order to keep your system up-to-date, make sure you have a list of the official repositories. You can find a list of the repositories available at Ikoula and installation instructions.[Quelles_sont_les_sources_des_d%C3%A9p%C3%B4ts_debian_chez_Ikoula| à cette adresse]].
Implementation
Create the chroot
One of the ways to set up a prison is to create a group that all imprisoned users depend on.
- Create the Group
groupadd chrootgrp
- Create our new user
adduser -g chrootgrp notre_utilisateur
Create directories
Nous devons maintenant mettre en place les répertoires de base de notre prison chroot afin de simuler la présence du répertoire racine /
- Create all directories
# la syntaxe { } nous permet de définir un répertoire et plusieurs sous-répertoires en une commande mkdir -p /var/jail/{dev,etc,lib,usr,bin} mkdir -p /var/jail/usr/bin
- Assigner les permissions aux répertoires créer afin de changer le propriétaire par root
chown root.root /var/jail
- Also create the file /dev/null
mknod -m 666 /var/jail/dev/null c 1 3
Configuration files /etc/
The configuration file /etc/ requires a few vital files in order to work properly, so we will copy them to our prison.
- Copy configuration files to the prison
# Se déplacer dans le dossier /etc/ de la prison cd /var/jail/etc # Copier les fichiers de configuration vers le répertoire courant . (/var/jail/etc/) cp /etc/ld.so.cache . cp /etc/ld.so.conf . cp /etc/nsswitch.conf . cp /etc/hosts .
Determine the available commands
We must now determine the commands that will be available to our user, for example the command ls, cat, and bash.
- We need to copy the executables to our prison
# Se déplacer dans le dossier /usr/bin de la prison cd /var/jail/usr/bin # Copier les exécutables souhaités vers le répertoire courant (/var/jail/usr/bin) cp /usr/bin/ls . cp /usr/bin/cat . cp /usr/bin/bash .
- Don't forget to add libraries shared for executables
# on cherche les bibliothèques de ls grâce à la commande ldd ldd /bin/ls # La commande retourne un résultat similaire: linux-gate.so.1 => (0xb7f2b000) librt.so.1 => /lib/librt.so.1 (0xb7f1d000) libacl.so.1 => /lib/libacl.so.1 (0xb7f16000) libc.so.6 => /lib/libc.so.6 (0xb7dcf000) libpthread.so.0 => /lib/libpthread.so.0 (0xb7db7000) /lib/ld-linux.so.2 (0xb7f2c000) libattr.so.1 => /lib/libattr.so.1 (0xb7db2000)
Configure the SSH service
Maintenant que notre prison est en place nous devons configurer le service SSH de façon à rediriger notre utilisateur appartenant au groupe chrooté vers son nouvel emplacement sécurisé.
- Edit the ssh configuration file
vi /etc/ssh/sshd_config
- Add the following content at the end of file
# Ajout du groupe chroot Match group chrootgrp ChrootDirectory /var/jail/ X11Forwarding no AllowTcpForwarding no
- Restart the ssh service
/etc/init.d/ssh restart
This configuration also disables the redirection X11 and the TCP port forwarding. In some cases, including the implementation of a secure tunnel, it may be necessary to review the configuration and remove the ban.
Option: Change the command prompt
This step is optional, if you test the connection to your prison you have the notice a prompt similar to this:
bash-2-5$
If you want to use a prompt less general simply to perform the following procedure:
# copier le contenu de /etc/skel vers /var/jail/home/votre_utilisateur cp /etc/skel/* /var/jail/home/notre_utilisateur/ # Vous avez à présent quelque chose comme ceci notre_utilisateur:->
Enable comment auto-refresher