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:

90693

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-11-26
ansible-compat - 26.11.1
Ebuild name:

dev-python/ansible-compat-26.11.1

Description

Contains functions that facilitate working with various versions

Added to portage

2026-11-26

bleachbit - 6.0.6
Ebuild name:

sys-apps/bleachbit-6.0.6

Description

Clean junk to free disk space and to maintain privacy

Added to portage

2026-11-26

c-blosc2 - 3.9.0
Ebuild name:

dev-libs/c-blosc2-3.9.0

Description

Blocking, shuffling and lossless compression library

Added to portage

2026-11-26

cachetools - 8.0.3
Ebuild name:

dev-python/cachetools-8.0.3

Description

Extensible memoizing collections and decorators

Added to portage

2026-11-26

cli-helpers - 2.15.5
Ebuild name:

dev-python/cli-helpers-2.15.5

Description

Python helpers for common CLI tasks

Added to portage

2026-11-26

cython - 3.3.2
Ebuild name:

dev-python/cython-3.3.2

Description

A Python to C compiler

Added to portage

2026-11-26

exim - 4.100.2
Ebuild name:

mail-mta/exim-4.100.2

Description

A highly configurable, drop-in replacement for sendmail

Added to portage

2026-11-26

fonttools - 4.69.1
Ebuild name:

dev-python/fonttools-4.69.1

Description

Library for manipulating TrueType, OpenType, AFM and Type1 fonts

Added to portage

2026-11-26

forbiddenfruit - 0.1.5
Ebuild name:

dev-python/forbiddenfruit-0.1.5

Description

Patch built-in Python objects

Added to portage

2026-11-26

fzf - 0.75.0
Ebuild name:

app-shells/fzf-0.75.0

Description

General-purpose command-line fuzzy finder, written in Golang

Added to portage

2026-11-26

gentoodo - 0.2.0
Ebuild name:

app-portage/gentoodo-0.2.0

Description

Generate reminder emails for Gentoo package maintainers

Added to portage

2026-11-26

httpd - 1.1-r1
Ebuild name:

app-emacs/httpd-1.1-r1

Description

A HTTP server embedded in the Emacs

Added to portage

2026-11-26

intellij-idea - 2026.3.0.1
Ebuild name:

dev-util/intellij-idea-2026.3.0.1

Description

A complete toolset for web, mobile and enterprise development

Added to portage

2026-11-26

markdown - 3.11.4
Ebuild name:

dev-python/markdown-3.11.4

Description

Python implementation of the markdown markup language

Added to portage

2026-11-26

pg_background - 2.0.5
Ebuild name:

dev-db/pg_background-2.0.5

Description

Postgres Background Worker

Added to portage

2026-11-26

pip - 26.3-r1
Ebuild name:

dev-python/pip-26.3-r1

Description

The PyPA recommended tool for installing Python packages

Added to portage

2026-11-26

pixi - 0.85.0
Ebuild name:

dev-util/pixi-0.85.0

Description

A package management and workflow tool

Added to portage

2026-11-26

pymongo - 4.20.2
Ebuild name:

dev-python/pymongo-4.20.2

Description

Python driver for MongoDB

Added to portage

2026-11-26

python-openstackclient - 10.6.0
Ebuild name:

dev-python/python-openstackclient-10.6.0

Description

A client for the OpenStack APIs

Added to portage

2026-11-26

qt5-sqlcipher - 1.1.0-r2
Ebuild name:

dev-db/qt5-sqlcipher-1.1.0-r2

Description

Qt SQL driver plugin for SQLCipher

Added to portage

2026-11-26

reaper-bin - 7.86-r3
Ebuild name:

media-sound/reaper-bin-7.86-r3

Description

Digital audio workstation

Added to portage

2026-11-26

regex - 2026.11.25
Ebuild name:

dev-python/regex-2026.11.25

Description

Alternative regular expression module to replace re

Added to portage

2026-11-26

testfixtures - 12.5.0
Ebuild name:

dev-python/testfixtures-12.5.0

Description

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

Added to portage

2026-11-26

thunderbird - 153.8.0
Ebuild name:

mail-client/thunderbird-153.8.0

Description

Thunderbird Mail Client

Added to portage

2026-11-26

thunderbird - 161.0
Ebuild name:

mail-client/thunderbird-161.0

Description

Thunderbird Mail Client

Added to portage

2026-11-26

thunderbird-bin - 153.8.0
Ebuild name:

mail-client/thunderbird-bin-153.8.0

Description

Thunderbird Mail Client

Added to portage

2026-11-26

thunderbird-bin - 161.0
Ebuild name:

mail-client/thunderbird-bin-161.0

Description

Thunderbird Mail Client

Added to portage

2026-11-26

thunderbird-l10n - 153.8.0
Ebuild name:

mail-client/thunderbird-l10n-153.8.0

Description

Thunderbird mail client's translation files

Added to portage

2026-11-26

thunderbird-l10n - 161.0
Ebuild name:

mail-client/thunderbird-l10n-161.0

Description

Thunderbird mail client's translation files

Added to portage

2026-11-26

urwid - 5.2.1
Ebuild name:

dev-python/urwid-5.2.1

Description

Curses-based user interface library for Python

Added to portage

2026-11-26

zope-schema - 8.2
Ebuild name:

dev-python/zope-schema-8.2

Description

Zope schema Architecture

Added to portage

2026-11-26

zstandard - 0.25.0-r1
Ebuild name:

dev-python/zstandard-0.25.0-r1

Description

Zstandard Bindings for Python

Added to portage

2026-11-26

2026-11-25
aioquic - 1.9.2
Ebuild name:

dev-python/aioquic-1.9.2

Description

An implementation of QUIC and HTTP/3

Added to portage

2026-11-25

aseprite - 1.3.18.6
Ebuild name:

dev-games/aseprite-1.3.18.6

Description

Animated sprite editor & pixel art tool

Added to portage

2026-11-25

aws-crt-cpp - 0.44.6
Ebuild name:

dev-cpp/aws-crt-cpp-0.44.6

Description

C++ wrapper around the aws-c-* libraries

Added to portage

2026-11-25

babel - 2.19.0
Ebuild name:

dev-python/babel-2.19.0

Description

Collection of tools for internationalizing Python applications

Added to portage

2026-11-25

dulwich - 1.2.22
Ebuild name:

dev-python/dulwich-1.2.22

Description

Pure-Python implementation of the Git file formats and protocols

Added to portage

2026-11-25

grafana-bin - 12.4.16
Ebuild name:

www-apps/grafana-bin-12.4.16

Description

Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & Ope

Added to portage

2026-11-25

grafana-bin - 13.1.11
Ebuild name:

www-apps/grafana-bin-13.1.11

Description

Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & Ope

Added to portage

2026-11-25

grafana-bin - 13.2.7
Ebuild name:

www-apps/grafana-bin-13.2.7

Description

Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & Open

Added to portage

2026-11-25

grafana-bin - 13.3.2
Ebuild name:

www-apps/grafana-bin-13.3.2

Description

Gorgeous metric viz, dashboards & editors for Graphite, InfluxDB & Open

Added to portage

2026-11-25

grpcio - 1.85.4
Ebuild name:

dev-python/grpcio-1.85.4

Description

HTTP/2-based RPC framework

Added to portage

2026-11-25

grpcio-status - 1.85.4
Ebuild name:

dev-python/grpcio-status-1.85.4

Description

Reference package for GRPC Python status proto mapping

Added to portage

2026-11-25

huawei-lte-api - 3.0.0
Ebuild name:

dev-python/huawei-lte-api-3.0.0

Description

API For huawei LAN/WAN LTE Modems

Added to portage

2026-11-25

kbfs - 9999
Ebuild name:

app-crypt/kbfs-9999

Description

Keybase Filesystem (KBFS)

Added to portage

2026-11-25

keepsecret - 26.08.3
Ebuild name:

app-crypt/keepsecret-26.08.3

Description

Password manager GUI for SecretService providers

Added to portage

2026-11-25

keybase - 6.0.2
Ebuild name:

app-crypt/keybase-6.0.2

Description

Keybase client

Added to portage

2026-11-25

keybase - 6.2.4
Ebuild name:

app-crypt/keybase-6.2.4

Description

Keybase client

Added to portage

2026-11-25

keybase - 9999
Ebuild name:

app-crypt/keybase-9999

Description

Keybase client

Added to portage

2026-11-25

krita - 6.0.5
Ebuild name:

media-gfx/krita-6.0.5

Description

Free digital painting application. Digital Painting, Creative Freedom

Added to portage

2026-11-25

libetonyek - 0.1.15
Ebuild name:

app-text/libetonyek-0.1.15

Description

Library parsing Apple Keynote presentations

Added to portage

2026-11-25

libetonyek - 9999
Ebuild name:

app-text/libetonyek-9999

Description

Library parsing Apple Keynote presentations

Added to portage

2026-11-25

libmspub - 0.1.6
Ebuild name:

app-text/libmspub-0.1.6

Description

Library parsing Microsoft Publisher documents

Added to portage

2026-11-25

libtmux - 0.68.0
Ebuild name:

dev-python/libtmux-0.68.0

Description

Typed library that provides an ORM wrapper for tmux, a terminal multiplex

Added to portage

2026-11-25

libvisio - 0.1.12
Ebuild name:

media-libs/libvisio-0.1.12

Description

Library parsing the file format of MS Visio documents

Added to portage

2026-11-25

linux-firmware - 20261124
Ebuild name:

sys-kernel/linux-firmware-20261124

Description

Linux firmware files

Added to portage

2026-11-25

ollama - 0.40.18
Ebuild name:

sci-ml/ollama-0.40.18

Description

Get up and running with Llama 3, Mistral, Gemma, and other language models

Added to portage

2026-11-25

openstacksdk - 4.25.0
Ebuild name:

dev-python/openstacksdk-4.25.0

Description

A collection of libraries for building applications to work with Ope

Added to portage

2026-11-25

pbs-installer - 2026.11.24
Ebuild name:

dev-python/pbs-installer-2026.11.24

Description

Installer for Python Build Standalone

Added to portage

2026-11-25

plotly - 7.2.0
Ebuild name:

dev-python/plotly-7.2.0

Description

Browser-based graphing library for Python

Added to portage

2026-11-25

pylsqpack - 1.1.3
Ebuild name:

dev-python/pylsqpack-1.1.3

Description

Python wrapper for the ls-qpack QPACK library

Added to portage

2026-11-25

pysnmp - 7.1.34
Ebuild name:

dev-python/pysnmp-7.1.34

Description

Python SNMP library

Added to portage

2026-11-25

python-glanceclient - 4.14.0
Ebuild name:

dev-python/python-glanceclient-4.14.0

Description

A client for the OpenStack Glance API

Added to portage

2026-11-25

quazip - 1.7.2
Ebuild name:

dev-libs/quazip-1.7.2

Description

Simple C++ wrapper over Gilles Vollant's ZIP/UNZIP package

Added to portage

2026-11-25

rr - 5.10.0
Ebuild name:

dev-debug/rr-5.10.0

Description

Record and Replay Framework

Added to portage

2026-11-25

simdjson - 5.3.0
Ebuild name:

dev-libs/simdjson-5.3.0

Description

SIMD accelerated C++ JSON library

Added to portage

2026-11-25

sqlglot - 30.35.0
Ebuild name:

dev-python/sqlglot-30.35.0

Description

An easily customizable SQL parser and transpiler

Added to portage

2026-11-25

tomlkit - 0.15.3
Ebuild name:

dev-python/tomlkit-0.15.3

Description

Style preserving TOML library

Added to portage

2026-11-25

trakit - 0.6.0
Ebuild name:

dev-python/trakit-0.6.0

Description

Identify a track from its title

Added to portage

2026-11-25

urwid - 5.2.0
Ebuild name:

dev-python/urwid-5.2.0

Description

Curses-based user interface library for Python

Added to portage

2026-11-25

uv - 0.13.10
Ebuild name:

dev-python/uv-0.13.10

Description

A Python package installer and resolver, written in Rust

Added to portage

2026-11-25

uv-build - 0.13.10
Ebuild name:

dev-python/uv-build-0.13.10

Description

PEP517 uv build backend

Added to portage

2026-11-25

wand - 0.7.3
Ebuild name:

dev-python/wand-0.7.3

Description

Ctypes-based simple ImageMagick binding for Python

Added to portage

2026-11-25

wine-proton - 11.0.3-r1
Ebuild name:

app-emulation/wine-proton-11.0.3-r1

Description

Valve Software's fork of Wine

Added to portage

2026-11-25

zellij - 0.46.1
Ebuild name:

app-misc/zellij-0.46.1

Description

A terminal workspace with batteries included

Added to portage

2026-11-25

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