• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Debian

Setting up a Chroot on Debian

How VPS by How VPS
November 1, 2019
in Debian
0
0
SHARES
24
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Step 1: Installing the dependencies
  2. Step 2: Creating the required directories
  3. Step 3 Copying over commands and their dependencies
  4. Step 4: Testing the environment
  5. Want to contribute?


This article will teach you how to setup a chroot jail on Debian. I assume that you’re using Debian 7.x. If you’re running Debian 6 or 8, this may work, but keep in mind that I haven’t tested other versions of Debian.

Log into your VPS as the root user. You may also run the commands with sudo.

Step 1: Installing the dependencies

To start off, you’ll need to run the following commands for installation, which will be explained later.

apt-get install binutils debootstrap

You’ll also need to choose a place to setup the chroot. For this article, we’ll using the /var/chroot directory.

Step 2: Creating the required directories

Make the chroot folder.

mkdir -p /var/chroot

Great! The preliminary steps have been completed. Now, let’s make the chroot useful.

Step 3 Copying over commands and their dependencies

We need a command interpreter, so let’s copy bash.

mkdir -p /var/chroot/bin
cp /bin/bash /var/chroot/bin

Every program has it’s own dependencies, and bash is one of them. Take a look at them by running:

ldd /bin/bash

It should look like this if you’re running a 32 bit version:

linux-gate.so.1 =>  (0xb773e000)
libtinfo.so.5 => /lib/i386-linux-gnu/libtinfo.so.5 (0xb7718000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb7714000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb75c3000)
/lib/ld-linux.so.2 (0xb773f000)

Let’s copy these files over. If you see different dependencies, just copy over the path after the => part.

mkdir -p /var/chroot/lib 
mkdir -p /var/chroot/lib/i386-linux-gnu
cp /lib/i386-linux-gnu/libtinfo.so.5 /var/chroot/lib/i386-linux-gnu
cp /lib/i386-linux-gnu/libdl.so.2 /var/chroot/lib/i386-linux-gnu
cp /lib/i386-linux-gnu/libc.so.6 /var/chroot/lib/i386-linux-gnu

Step 4: Testing the environment

Now that we have bash setup – let’s test it.

chroot /var/chroot

The bash command interpreter will open, but there won’t be any other commands to run. This is because we haven’t copied any other programs over to the chroot folder. If you want more commands, type exit and repeat step 3.

That’s all it takes. You now have a basic chroot set up. You can test commands, jail your users, etc.

If you want networking in the chroot, you’ll need to run the following commands

mkdir -p /var/chroot/etc
cp /etc/resolv.conf /var/chroot/etc
cp /etc/gai.conf /var/chroot/etc

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

Setup Your Own DNS Server on Debian/Ubuntu

Next Post

Build Your Social Network With Diaspora on Debian 9

Next Post

Build Your Social Network With Diaspora on Debian 9

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet