Difference between revisions of "Chroot Debian users"
(Created page with "<br /> This article has been created by an automatic translation software. You can view the article source here.<br /><span data-tran...") |
|||
(20 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | <br /> | + | <span data-link_translate_fr_title="Chrooter ses utilisateurs Debian" data-link_translate_fr_url="Chrooter ses utilisateurs Debian"></span>[[:fr:Chrooter ses utilisateurs Debian]][[fr:Chrooter ses utilisateurs Debian]] |
+ | <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_es_title="Usuarios de Debian chroot" data-link_translate_es_url="Usuarios de Debian chroot"></span>[[:es:Usuarios de Debian chroot]][[es:Usuarios de Debian chroot]] | ||
+ | <span data-link_translate_pt_title="Usuários Debian chroot" data-link_translate_pt_url="Usuários Debian chroot"></span>[[:pt:Usuários Debian chroot]][[pt:Usuários Debian chroot]] | ||
+ | <span data-link_translate_it_title="Utenti Debian chroot" data-link_translate_it_url="Utenti Debian chroot"></span>[[:it:Utenti Debian chroot]][[it:Utenti Debian chroot]] | ||
+ | <span data-link_translate_nl_title="Chroot Debian gebruikers" data-link_translate_nl_url="Chroot Debian gebruikers"></span>[[:nl:Chroot Debian gebruikers]][[nl:Chroot Debian gebruikers]] | ||
+ | <span data-link_translate_de_title="Debian-Chroot-Benutzer" data-link_translate_de_url="Debian-Chroot-Benutzer"></span>[[:de:Debian-Chroot-Benutzer]][[de:Debian-Chroot-Benutzer]] | ||
+ | <span data-link_translate_zh_title="Chroot Debian 用户" data-link_translate_zh_url="Chroot Debian 用户"></span>[[:zh:Chroot Debian 用户]][[zh:Chroot Debian 用户]] | ||
+ | <span data-link_translate_ar_title="مستخدمي ديبيان استجذار" data-link_translate_ar_url="مستخدمي ديبيان استجذار"></span>[[:ar:مستخدمي ديبيان استجذار]][[ar:مستخدمي ديبيان استجذار]] | ||
+ | <span data-link_translate_ja_title="Chroot Debian ユーザ" data-link_translate_ja_url="Chroot Debian ユーザ"></span>[[:ja:Chroot Debian ユーザ]][[ja:Chroot Debian ユーザ]] | ||
+ | <span data-link_translate_pl_title="Użytkownicy Debiana chroot" data-link_translate_pl_url="Użytkownicy Debiana chroot"></span>[[:pl:Użytkownicy Debiana chroot]][[pl:Użytkownicy Debiana chroot]] | ||
+ | <span data-link_translate_ru_title="Пользователи Debian chroot" data-link_translate_ru_url="Пользователи Debian chroot"></span>[[:ru:Пользователи Debian chroot]][[ru:Пользователи Debian chroot]] | ||
+ | <span data-link_translate_ro_title="Utilizatorii Debian chroot" data-link_translate_ro_url="Utilizatorii Debian chroot"></span>[[:ro:Utilizatorii Debian chroot]][[ro:Utilizatorii Debian chroot]] | ||
+ | <span data-link_translate_he_title="משתמשי דביאן Chroot" data-link_translate_he_url="משתמשי דביאן Chroot"></span>[[:he:משתמשי דביאן Chroot]][[he:משתמשי דביאן Chroot]] | ||
+ | <br />This article has been created by an automatic translation software. You can view the article source [[:fr:Chrooter ses utilisateurs Debian|here]].<br /><span data-translate="fr"></span><br /> | ||
+ | <span data-link_translate_fr_title="Chrooter ses utilisateurs Debian" data-link_translate_fr_url="Chrooter ses utilisateurs Debian"></span>[[:fr:Chrooter ses utilisateurs Debian]][[fr:Chrooter ses utilisateurs Debian]] | ||
+ | <span data-link_translate_he_title="משתמשי דביאן Chroot" data-link_translate_he_url="%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9%D7%99+%D7%93%D7%91%D7%99%D7%90%D7%9F+Chroot"></span>[[:he:משתמשי דביאן Chroot]][[he:משתמשי דביאן Chroot]] | ||
+ | <span data-link_translate_ru_title="Пользователи Debian chroot" data-link_translate_ru_url="%D0%9F%D0%BE%D0%BB%D1%8C%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D0%B5%D0%BB%D0%B8+Debian+chroot"></span>[[:ru:Пользователи Debian chroot]][[ru:Пользователи Debian chroot]] | ||
+ | <span data-link_translate_ja_title="Chroot Debian ユーザ" data-link_translate_ja_url="Chroot+Debian+%E3%83%A6%E3%83%BC%E3%82%B6"></span>[[:ja:Chroot Debian ユーザ]][[ja:Chroot Debian ユーザ]] | ||
+ | <span data-link_translate_ar_title="مستخدمي ديبيان استجذار" data-link_translate_ar_url="%D9%85%D8%B3%D8%AA%D8%AE%D8%AF%D9%85%D9%8A+%D8%AF%D9%8A%D8%A8%D9%8A%D8%A7%D9%86+%D8%A7%D8%B3%D8%AA%D8%AC%D8%B0%D8%A7%D8%B1"></span>[[:ar:مستخدمي ديبيان استجذار]][[ar:مستخدمي ديبيان استجذار]] | ||
+ | <span data-link_translate_zh_title="Chroot Debian 用户" data-link_translate_zh_url="Chroot+Debian+%E7%94%A8%E6%88%B7"></span>[[:zh:Chroot Debian 用户]][[zh:Chroot Debian 用户]] | ||
+ | <span data-link_translate_ro_title="Utilizatorii Debian chroot" data-link_translate_ro_url="Utilizatorii+Debian+chroot"></span>[[:ro:Utilizatorii Debian chroot]][[ro:Utilizatorii Debian chroot]] | ||
+ | <span data-link_translate_pl_title="Użytkownicy Debiana chroot" data-link_translate_pl_url="U%C5%BCytkownicy+Debiana+chroot"></span>[[:pl:Użytkownicy Debiana chroot]][[pl:Użytkownicy Debiana chroot]] | ||
+ | <span data-link_translate_de_title="Debian-Chroot-Benutzer" data-link_translate_de_url="Debian-Chroot-Benutzer"></span>[[:de:Debian-Chroot-Benutzer]][[de:Debian-Chroot-Benutzer]] | ||
+ | <span data-link_translate_nl_title="Chroot Debian gebruikers" data-link_translate_nl_url="Chroot+Debian+gebruikers"></span>[[:nl:Chroot Debian gebruikers]][[nl:Chroot Debian gebruikers]] | ||
+ | <span data-link_translate_it_title="Utenti Debian chroot" data-link_translate_it_url="Utenti+Debian+chroot"></span>[[:it:Utenti Debian chroot]][[it:Utenti Debian chroot]] | ||
+ | <span data-link_translate_pt_title="Usuários Debian chroot" data-link_translate_pt_url="Usu%C3%A1rios+Debian+chroot"></span>[[:pt:Usuários Debian chroot]][[pt:Usuários Debian chroot]] | ||
+ | <span data-link_translate_es_title="Usuarios de Debian chroot" data-link_translate_es_url="Usuarios+de+Debian+chroot"></span>[[:es:Usuarios de Debian chroot]][[es:Usuarios de Debian chroot]] | ||
+ | <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: | |
+ | |title=Chroot Debian users | ||
+ | |title_mode=append | ||
+ | |keywords=these,are,your,keywords | ||
+ | |description=Discover in this article how to chroot Debian users | ||
+ | |image=Uploaded_file.png | ||
+ | |image_alt=Wiki Logo | ||
+ | }} | ||
==Introduction== | ==Introduction== | ||
− | + | Il peut être utile de '''chrooter''' ses utilisateurs afin de limiter leur liberté de mouvements au sein de son système.<br> | |
− | <div style="background-color: #FF9999;"> ''' | + | <div style="background-color: #FF9999;"> '''Avertissement''': Avant toute modification de votre système prévoyez toujours une {{Template:Sauvegarde}} de vos fichiers en cas de mauvaise manipulation.<br> |
− | + | Sur un {{Template:Serveur}} de production, pensez à effectuer ces opérations pendant les heures creuses afin de minimiser l'impact de vos actions.</div> | |
− | == | + | ==Prerequisites== |
− | One of the | + | One of the prerequisites essential is to keep its system as up-to-date as possible.<br> |
<pre> apt-get update | <pre> apt-get update | ||
apt-get upgrade </pre> | apt-get upgrade </pre> | ||
− | + | 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 === | + | ===Create the chroot=== |
− | One of the ways to | + | One of the ways to set up a prison is to create a group that all imprisoned users depend on. |
− | ;Create Group | + | ;Create the Group |
<pre> groupadd chrootgrp </pre> | <pre> groupadd chrootgrp </pre> | ||
− | ;Create our new user | + | ;Create our new user |
<pre> adduser -g chrootgrp notre_utilisateur </pre> | <pre> adduser -g chrootgrp notre_utilisateur </pre> | ||
− | ===Create | + | ===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 | + | ; Create all directories |
<pre> # la syntaxe { } nous permet de définir un répertoire et plusieurs sous-répertoires en une commande | <pre> # 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/{dev,etc,lib,usr,bin} | ||
mkdir -p /var/jail/usr/bin</pre> | mkdir -p /var/jail/usr/bin</pre> | ||
− | ; | + | ;Assigner les permissions aux répertoires créer afin de changer le propriétaire par ''root'' |
<pre> chown root.root /var/jail </pre> | <pre> chown root.root /var/jail </pre> | ||
− | ;Also create the file | + | ;Also create the file ''/dev/null'' |
<pre> mknod -m 666 /var/jail/dev/null c 1 3 </pre> | <pre> mknod -m 666 /var/jail/dev/null c 1 3 </pre> | ||
− | ===Configuration files | + | ===Configuration files /etc/=== |
− | The configuration file | + | 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 prison | + | ;Copy configuration files to the prison |
<pre> # Se déplacer dans le dossier /etc/ de la prison | <pre> # Se déplacer dans le dossier /etc/ de la prison | ||
cd /var/jail/etc | cd /var/jail/etc | ||
Line 40: | Line 75: | ||
cp /etc/hosts . | cp /etc/hosts . | ||
</pre> | </pre> | ||
− | ===Determine the commands === | + | ===Determine the available commands=== |
− | We must now determine the commands that will be | + | 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 |
<pre> # Se déplacer dans le dossier /usr/bin de la prison | <pre> # Se déplacer dans le dossier /usr/bin de la prison | ||
cd /var/jail/usr/bin | cd /var/jail/usr/bin | ||
Line 50: | Line 85: | ||
cp /usr/bin/bash . | cp /usr/bin/bash . | ||
</pre> | </pre> | ||
− | ;Don't forget to add | + | ;Don't forget to add libraries shared for executables |
<pre> # on cherche les bibliothèques de ls grâce à la commande ldd | <pre> # on cherche les bibliothèques de ls grâce à la commande ldd | ||
ldd /bin/ls | ldd /bin/ls | ||
Line 62: | Line 97: | ||
libattr.so.1 => /lib/libattr.so.1 (0xb7db2000) | libattr.so.1 => /lib/libattr.so.1 (0xb7db2000) | ||
</pre> | </pre> | ||
− | ===Configure the SSH | + | ===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 | + | ;Edit the ssh configuration file |
<pre> vi /etc/ssh/sshd_config </pre> | <pre> vi /etc/ssh/sshd_config </pre> | ||
− | ;Add the following content at the end of | + | ;Add the following content at the end of file |
<pre> # Ajout du groupe chroot | <pre> # Ajout du groupe chroot | ||
Match group chrootgrp | Match group chrootgrp | ||
Line 73: | Line 108: | ||
AllowTcpForwarding no | AllowTcpForwarding no | ||
</pre> | </pre> | ||
− | ;Restart the ssh service | + | ;Restart the ssh service |
<pre> /etc/init.d/ssh restart </pre> | <pre> /etc/init.d/ssh restart </pre> | ||
− | This configuration also disables the redirection | + | 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 prompt=== | + | ===Option: Change the command prompt=== |
− | This step is optional, if you test the connection to your prison you | + | This step is optional, if you test the connection to your prison you have the notice a prompt similar to this: |
<pre> bash-2-5$ </pre> | <pre> bash-2-5$ </pre> | ||
If you want to use a prompt less general simply to perform the following procedure: | If you want to use a prompt less general simply to perform the following procedure: | ||
Line 89: | Line 124: | ||
[[Category:Dedicated_server]] | [[Category:Dedicated_server]] | ||
[[Category:Linux]] | [[Category:Linux]] | ||
− | |||
<br /> | <br /> | ||
<comments /> | <comments /> |
Latest revision as of 17:13, 24 September 2021
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