from small one page howto to huge articles all in one place

search text in:




Other .linuxhowtos.org sites: www.linuxhowtos.org
toolsntoys.linuxhowtos.org



Last additions:
How to make X listen on port 6000

How to make X listen on port 6000

words:

34

views:

86153

userrating:

average rating: 1.2 (52 votes) (1=very good 6=terrible)


May, 25th 2007:
April, 26th 2007:
Apr, 10th. 2007:
Druckversion . pdf icon
You are here: Tutorials per portage category->net-misc->openssh

Create a chrooted ssh user

This tutorial explains how to install and configure a chroot enviroment for an ssh user. This setup enables you to give out ssh accounts without having to fear that this user can see all files on the system.

Installing ssh

First you need to have a patched version of the sshd server. Luckily these patches can be enabled with the use flag "chroot" in the sshd use flags.
#echo "net-misc/openssh chroot" >> /etc/portage/package.use
#emerge openssh

creating the chroot enviroment

We will create our chroot enviroment in /home/chroot.
To make the chroot work, run the following commands to make the needed directories and devices for the chrooted user.
mkdir /home/chroot/
mkdir /home/chroot/home/
cd /home/chroot
mkdir etc
mkdir bin
mkdir lib
mkdir usr
mkdir usr/bin
mkdir dev
mknod dev/null c 1 3
mknod dev/zero c 1 5

Now we need to populate the directories with some binaries.
copy the following script into a file. If you need more apps, add them
to the APPS line.

APPS="/bin/bash /bin/ls /bin/mkdir /bin/mv /bin/pwd /bin/rm /usr/bin/id /usr/bin/ssh /bin/ping /usr/bin/dircolors"
for prog in $APPS; do
cp $prog ./$prog

# obtain a list of related libraries
ldd $prog > /dev/null
if [ "$?" = 0 ] ; then
LIBS=`ldd $prog | awk '{ print $3 }'`
for l in $LIBS; do
mkdir ./`dirname $l` > /dev/null 2>&1
cp $l ./$l
done
fi
done

After you have run the script, your chroot enviroment is almost done.
run

cp /lib/libnss_compat.so.2 /lib/libnsl.so.1 /lib/libnss_files.so.2 ./lib/
echo '#!/bin/bash' > usr/bin/groups
echo "id -Gn" >> usr/bin/groups
touch etc/passwd
grep /etc/passwd -e "^root" > etc/passwd
to copy some libraries and user information into the chroot.
You should also copy the line of the group in which you will create new users from /etc/group to /home/chroot/etc/group. In this tutorial we will create users in the group users, so we do this:
grep /etc/group -e "^root" -e "^users" > etc/group

and restart SSH:
/etc/init.d/ssh restart

Creating chrooted users

ssh decides which user should be chrooted and which not by the "home directory" entry in the /etc/passwd.
Example for a non-chrooted user:
user_a:x:2002:100:User A:/home/user_a:/bin/bash
This user will be chrooted:
user_b:x:2003:100:User B:/home/chroot/./home/user_b:/bin/bash
Now lets add a testuser to the chrooted user list:
useradd -s /bin/bash -m -d /home/chroot/./home/testuser -c "testuser" -g users testuser

Then we give testuser a password:
passwd testuser

Finally, we have to copy the line for testuser in /etc/passwd to /home/chroot/etc/passwd:
grep /etc/passwd -e "^testuser" >> /home/chroot/etc/passwd


Now log in as testuser and see if everything worked.

Have fun
back



Support us on Content Nation

New Packages

- as rdf newsfeed
- as rss newsfeed
- as Atom newsfeed
2026-06-22
pkgcore - 0.12.35
Ebuild name:

sys-apps/pkgcore-0.12.35

Description

a framework for package management

Added to portage

2026-06-22

xfce4-settings - 4.21.2
Ebuild name:

xfce-base/xfce4-settings-4.21.2

Description

Configuration system for the Xfce desktop environment

Added to portage

2026-06-22

xfdesktop - 4.21.0
Ebuild name:

xfce-base/xfdesktop-4.21.0

Description

Desktop manager for the Xfce desktop environment

Added to portage

2026-06-22

2026-06-21
cereal - 1.3.2-r4
Ebuild name:

dev-libs/cereal-1.3.2-r4

Description

Header-only C++11 serialization library

Added to portage

2026-06-21

coverage - 7.14.2
Ebuild name:

dev-python/coverage-7.14.2

Description

Code coverage measurement for Python

Added to portage

2026-06-21

dash - 0.5.13.4-r2
Ebuild name:

app-shells/dash-0.5.13.4-r2

Description

Debian Almquist Shell

Added to portage

2026-06-21

eselect-pinentry - 0.7.5
Ebuild name:

app-eselect/eselect-pinentry-0.7.5

Description

Manage /usr/bin/pinentry symlink

Added to portage

2026-06-21

ffmpeg - 6.1.6
Ebuild name:

media-video/ffmpeg-6.1.6

Description

Complete solution to record/convert/stream audio and video

Added to portage

2026-06-21

ffmpeg-compat - 6.1.6
Ebuild name:

media-video/ffmpeg-compat-6.1.6

Description

Complete solution to record/convert/stream audio and video

Added to portage

2026-06-21

firefox - 152.0.1
Ebuild name:

www-client/firefox-152.0.1

Description

Firefox Web Browser

Added to portage

2026-06-21

firefox-bin - 152.0.1
Ebuild name:

www-client/firefox-bin-152.0.1

Description

Firefox Web Browser

Added to portage

2026-06-21

firefox-l10n - 152.0.1
Ebuild name:

www-client/firefox-l10n-152.0.1

Description

Firefox Web Browser's translation files

Added to portage

2026-06-21

freedroid - 1.9.1
Ebuild name:

games-rpg/freedroid-1.9.1

Description

The original Freedroid, a clone of the C64 classic Paradroid

Added to portage

2026-06-21

gcc - 16.1.1_p20260620
Ebuild name:

sys-devel/gcc-16.1.1_p20260620

Description

The GNU Compiler Collection

Added to portage

2026-06-21

gentoo-kernel-modprep - 6.1.176
Ebuild name:

sys-kernel/gentoo-kernel-modprep-6.1.176

Description

Minimal subset of gentoo-kernel-bin for building modules,

Added to portage

2026-06-21

gentoo-kernel-modprep - 6.12.94
Ebuild name:

sys-kernel/gentoo-kernel-modprep-6.12.94

Description

Minimal subset of gentoo-kernel-bin for building modules,

Added to portage

2026-06-21

gentoo-kernel-modprep - 6.18.36
Ebuild name:

sys-kernel/gentoo-kernel-modprep-6.18.36

Description

Minimal subset of gentoo-kernel-bin for building modules,

Added to portage

2026-06-21

gentoo-kernel-modprep - 6.6.143
Ebuild name:

sys-kernel/gentoo-kernel-modprep-6.6.143

Description

Minimal subset of gentoo-kernel-bin for building modules,

Added to portage

2026-06-21

global - 6.6.15
Ebuild name:

dev-util/global-6.6.15

Description

Tag system to find an object location in various sources

Added to portage

2026-06-21

jq - 1.8.2
Ebuild name:

app-misc/jq-1.8.2

Description

A lightweight and flexible command-line JSON processor

Added to portage

2026-06-21

kquickimageeditor - 0.6.2
Ebuild name:

media-libs/kquickimageeditor-0.6.2

Description

QtQuick components providing basic image editing capabilities

Added to portage

2026-06-21

lttng-modules - 2.14.6
Ebuild name:

dev-util/lttng-modules-2.14.6

Description

LTTng Kernel Tracer Modules

Added to portage

2026-06-21

lttng-tools - 2.14.2
Ebuild name:

dev-util/lttng-tools-2.14.2

Description

Linux Trace Toolkit - next generation

Added to portage

2026-06-21

mycli - 1.76.0
Ebuild name:

dev-db/mycli-1.76.0

Description

CLI for MySQL Database with auto-completion and syntax highlighting

Added to portage

2026-06-21

naev - 0.13.5
Ebuild name:

games-strategy/naev-0.13.5

Description

2D space trading and combat game, in a similar vein to Escape Velocity

Added to portage

2026-06-21

openpgp-keys-jeremiegalarneau - 20260620
Ebuild name:

sec-keys/openpgp-keys-jeremiegalarneau-20260620

Description

OpenPGP keys used by Jérémie Galarneau

Added to portage

2026-06-21

openrc - 0.63.2
Ebuild name:

sys-apps/openrc-0.63.2

Description

OpenRC manages the services, startup and shutdown of a host

Added to portage

2026-06-21

postgrey - 1.37_p20230714-r2
Ebuild name:

mail-filter/postgrey-1.37_p20230714-r2

Description

Postgrey is a Postfix policy server implementing greylisting

Added to portage

2026-06-21

pysolfc - 3.6.0
Ebuild name:

games-board/pysolfc-3.6.0

Description

Exciting collection of more than 1000 solitaire card games

Added to portage

2026-06-21

python-engineio - 4.13.3
Ebuild name:

dev-python/python-engineio-4.13.3

Description

Python implementation of the Engine.IO realtime server

Added to portage

2026-06-21

qbs - 3.3.0
Ebuild name:

dev-util/qbs-3.3.0

Description

Modern build tool for software projects

Added to portage

2026-06-21

qxlsx - 1.5.1.1
Ebuild name:

dev-libs/qxlsx-1.5.1.1

Description

Excel file(*.xlsx) reader/writer library using Qt

Added to portage

2026-06-21

rapidyaml - 0.15.2
Ebuild name:

dev-cpp/rapidyaml-0.15.2

Description

Library to parse and emit YAML, and do it fast

Added to portage

2026-06-21

rq - 2.10.0
Ebuild name:

dev-python/rq-2.10.0

Description

Simple, lightweight library for creating and processing background jobs

Added to portage

2026-06-21

scummvm - 2026.3.0
Ebuild name:

games-engines/scummvm-2026.3.0

Description

Reimplementation of various game engines for adventures and role-pla

Added to portage

2026-06-21

shutter - 0.99.7
Ebuild name:

x11-misc/shutter-0.99.7

Description

Feature-rich screenshot program

Added to portage

2026-06-21

signxml - 5.0.0
Ebuild name:

dev-python/signxml-5.0.0

Description

Python XML Signature and XAdES library

Added to portage

2026-06-21

systemd - 261-r1
Ebuild name:

sys-apps/systemd-261-r1

Description

System and service manager for Linux

Added to portage

2026-06-21

testfixtures - 12.2.0
Ebuild name:

dev-python/testfixtures-12.2.0

Description

A collection of helpers and mock objects for unit tests and doc test

Added to portage

2026-06-21

tibs - 0.10.0
Ebuild name:

dev-python/tibs-0.10.0

Description

A sleek Python library for your binary data

Added to portage

2026-06-21

ueberzugpp - 2.9.10
Ebuild name:

media-gfx/ueberzugpp-2.9.10

Description

Drop in replacement for ueberzug written in C++

Added to portage

2026-06-21

vips - 8.18.3
Ebuild name:

media-libs/vips-8.18.3

Description

VIPS Image Processing Library

Added to portage

2026-06-21

virtualbox-modules - 7.2.10-r1
Ebuild name:

app-emulation/virtualbox-modules-7.2.10-r1

Description

Kernel Modules for Virtualbox

Added to portage

2026-06-21

wrapt - 2.2.2
Ebuild name:

dev-python/wrapt-2.2.2

Description

Module for decorators, wrappers and monkey patching

Added to portage

2026-06-21

yaspin - 3.4.0
Ebuild name:

dev-python/yaspin-3.4.0

Description

Yet Another Terminal Spinner

Added to portage

2026-06-21

zsnes - 2.1.1
Ebuild name:

games-emulation/zsnes-2.1.1

Description

Fork of the classic Super Nintendo emulator

Added to portage

2026-06-21

rdf newsfeed | rss newsfeed | Atom newsfeed
Copyright 2004-2025 Sascha Nitsch Unternehmensberatung GmbH
- Copyright and legal notices -
Time to create this page: 98.4 ms