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:

87247

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-07-28
accountsservice - 23.13.9-r1
Ebuild name:

sys-apps/accountsservice-23.13.9-r1

Description

D-Bus interfaces for querying and manipulating user account inf

Added to portage

2026-07-28

accountsservice - 26.27.3
Ebuild name:

sys-apps/accountsservice-26.27.3

Description

D-Bus interfaces for querying and manipulating user account inform

Added to portage

2026-07-28

awscli - 1.45.57
Ebuild name:

app-admin/awscli-1.45.57

Description

Universal Command Line Environment for AWS

Added to portage

2026-07-28

boto3 - 1.43.57
Ebuild name:

dev-python/boto3-1.43.57

Description

The AWS SDK for Python

Added to portage

2026-07-28

botocore - 1.43.57
Ebuild name:

dev-python/botocore-1.43.57

Description

Low-level, data-driven core of boto 3

Added to portage

2026-07-28

brotli - 0.8.0-r1
Ebuild name:

dev-ruby/brotli-0.8.0-r1

Description

Brotli compressor/decompressor

Added to portage

2026-07-28

c-blosc2 - 3.3.0
Ebuild name:

dev-libs/c-blosc2-3.3.0

Description

Blocking, shuffling and lossless compression library

Added to portage

2026-07-28

cachebox - 6.2.1
Ebuild name:

dev-python/cachebox-6.2.1

Description

The fastest memoizing and caching Python library written in Rust

Added to portage

2026-07-28

cssselect - 1.5.0
Ebuild name:

dev-python/cssselect-1.5.0

Description

Parse CSS3 Selectors and translate them to XPath 1.0

Added to portage

2026-07-28

deepdiff - 9.1.0
Ebuild name:

dev-python/deepdiff-9.1.0

Description

A library for comparing dictionaries, iterables, strings and other object

Added to portage

2026-07-28

fastapi - 0.140.7
Ebuild name:

dev-python/fastapi-0.140.7

Description

High performance framework, easy to learn, fast to code, ready for produ

Added to portage

2026-07-28

fastbencode - 0.3.11
Ebuild name:

dev-python/fastbencode-0.3.11

Description

Implementation of bencode with Rust implementation

Added to portage

2026-07-28

fastjsonschema - 2.22.1
Ebuild name:

dev-python/fastjsonschema-2.22.1

Description

Fast JSON schema validator for Python

Added to portage

2026-07-28

gdm - 49.3-r2
Ebuild name:

gnome-base/gdm-49.3-r2

Description

GNOME Display Manager for managing graphical display servers and user logins

Added to portage

2026-07-28

gnome-control-center - 49.8-r1
Ebuild name:

gnome-base/gnome-control-center-49.8-r1

Description

GNOME's main interface to configure various aspects of the

Added to portage

2026-07-28

gnome-flashback-herbstluftwm - 1.0
Ebuild name:

x11-wm/gnome-flashback-herbstluftwm-1.0

Description

GNOME Herbstluftwm session (via GNOME Flashback)

Added to portage

2026-07-28

gnome-shell-extension-appindicator - 65
Ebuild name:

gnome-extra/gnome-shell-extension-appindicator-65

Description

Support legacy, AppIndicators and KStatusNotifier

Added to portage

2026-07-28

guile - 3.0.11-r1
Ebuild name:

dev-scheme/guile-3.0.11-r1

Description

GNU Ubiquitous Intelligent Language for Extensions

Added to portage

2026-07-28

hypothesis - 6.161.8
Ebuild name:

dev-python/hypothesis-6.161.8

Description

A library for property based testing

Added to portage

2026-07-28

inline-snapshot - 0.35.3
Ebuild name:

dev-python/inline-snapshot-0.35.3

Description

Create and update inline snapshots in your Python tests

Added to portage

2026-07-28

krita - 6.0.3
Ebuild name:

media-gfx/krita-6.0.3

Description

Free digital painting application. Digital Painting, Creative Freedom

Added to portage

2026-07-28

libwebsockets - 5.0.0-r1
Ebuild name:

net-libs/libwebsockets-5.0.0-r1

Description

A flexible pure-C library for implementing network protocols

Added to portage

2026-07-28

psych - 5.4.0
Ebuild name:

dev-ruby/psych-5.4.0

Description

A YAML parser and emitter

Added to portage

2026-07-28

pyproject-fmt - 2.26.0
Ebuild name:

dev-python/pyproject-fmt-2.26.0

Description

Format your pyproject.toml file

Added to portage

2026-07-28

pyquery - 2.0.2
Ebuild name:

dev-python/pyquery-2.0.2

Description

A jQuery-like library for python

Added to portage

2026-07-28

pyquery - 2.1.0
Ebuild name:

dev-python/pyquery-2.1.0

Description

A jQuery-like library for python

Added to portage

2026-07-28

python-lsp-server - 1.15.0
Ebuild name:

dev-python/python-lsp-server-1.15.0

Description

Python Language Server for the Language Server Protocol

Added to portage

2026-07-28

ruff - 0.16.0
Ebuild name:

dev-util/ruff-0.16.0

Description

An extremely fast Python linter, written in Rust

Added to portage

2026-07-28

samba - 4.23.10
Ebuild name:

net-fs/samba-4.23.10

Description

Samba Suite Version 4

Added to portage

2026-07-28

samba - 4.24.5
Ebuild name:

net-fs/samba-4.24.5

Description

Samba Suite Version 4

Added to portage

2026-07-28

sqlglot - 30.14.0
Ebuild name:

dev-python/sqlglot-30.14.0

Description

An easily customizable SQL parser and transpiler

Added to portage

2026-07-28

tailscale - 1.102.0
Ebuild name:

net-vpn/tailscale-1.102.0

Description

Tailscale vpn client

Added to portage

2026-07-28

tekore - 6.2.0
Ebuild name:

dev-python/tekore-6.2.0

Description

Spotify Web API client

Added to portage

2026-07-28

tqdm - 4.70.0
Ebuild name:

dev-python/tqdm-4.70.0

Description

Add a progress meter to your loops in a second

Added to portage

2026-07-28

ttyd - 1.7.7-r2
Ebuild name:

www-apps/ttyd-1.7.7-r2

Description

ttyd, a simple command-line tool for sharing terminal over the web

Added to portage

2026-07-28

twine - 7.0.0
Ebuild name:

dev-python/twine-7.0.0

Description

Collection of utilities for publishing packages on PyPI

Added to portage

2026-07-28

zoom - 7.0.0.1666-r2
Ebuild name:

net-im/zoom-7.0.0.1666-r2

Description

Video conferencing and web conferencing service

Added to portage

2026-07-28

2026-07-27
atari800 - 7.1.2
Ebuild name:

games-emulation/atari800-7.1.2

Description

Emulator of Atari 8-bit computer systems and 5200 game console

Added to portage

2026-07-27

backrefs - 8.0
Ebuild name:

dev-python/backrefs-8.0

Description

Wrapper around re or regex that adds additional back references

Added to portage

2026-07-27

cares-tools - 0.4
Ebuild name:

net-dns/cares-tools-0.4

Description

c-ares tools host, nslookup

Added to portage

2026-07-27

courier - 2.0.6
Ebuild name:

mail-mta/courier-2.0.6

Description

An MTA designed specifically for maildirs

Added to portage

2026-07-27

fastjsonschema - 2.22.0
Ebuild name:

dev-python/fastjsonschema-2.22.0

Description

Fast JSON schema validator for Python

Added to portage

2026-07-27

gamescope - 3.16.25-r1
Ebuild name:

gui-wm/gamescope-3.16.25-r1

Description

Efficient micro-compositor for running games

Added to portage

2026-07-27

gcc - 13.4.1_p20260722
Ebuild name:

sys-devel/gcc-13.4.1_p20260722

Description

The GNU Compiler Collection

Added to portage

2026-07-27

gcc - 14.4.1_p20260723
Ebuild name:

sys-devel/gcc-14.4.1_p20260723

Description

The GNU Compiler Collection

Added to portage

2026-07-27

gcc - 15.3.1_p20260724
Ebuild name:

sys-devel/gcc-15.3.1_p20260724

Description

The GNU Compiler Collection

Added to portage

2026-07-27

gcc - 16.1.1_p20260725
Ebuild name:

sys-devel/gcc-16.1.1_p20260725

Description

The GNU Compiler Collection

Added to portage

2026-07-27

gcc - 17.0.0_p20260726
Ebuild name:

sys-devel/gcc-17.0.0_p20260726

Description

The GNU Compiler Collection

Added to portage

2026-07-27

geekbench-ai - 1.7.0
Ebuild name:

app-benchmarks/geekbench-ai-1.7.0

Description

A Cross-Platform AI Benchmark for Android, iOS, Linux, MacOS and

Added to portage

2026-07-27

git-sources - 7.2_rc5
Ebuild name:

sys-kernel/git-sources-7.2_rc5

Description

The very latest -git version of the Linux kernel

Added to portage

2026-07-27

gitpython - 3.1.57
Ebuild name:

dev-python/gitpython-3.1.57

Description

Library used to interact with Git repositories

Added to portage

2026-07-27

gnome-flashback - 3.58.0-r1
Ebuild name:

gnome-base/gnome-flashback-3.58.0-r1

Description

GNOME Flashback session

Added to portage

2026-07-27

herbstluftwm - 0.9.6-r1
Ebuild name:

x11-wm/herbstluftwm-0.9.6-r1

Description

A manual tiling window manager for X

Added to portage

2026-07-27

jupyterlab-desktop-bin - 4.6.2.1
Ebuild name:

sci-misc/jupyterlab-desktop-bin-4.6.2.1

Description

JupyterLab desktop application, based on Electron

Added to portage

2026-07-27

libGLw - 8.0.0-r2
Ebuild name:

x11-libs/libGLw-8.0.0-r2

Description

Mesa GLw library

Added to portage

2026-07-27

libxmp - 4.7.2
Ebuild name:

media-libs/libxmp-4.7.2

Description

Library that renders module files to PCM data

Added to portage

2026-07-27

libzia - 4.72-r1
Ebuild name:

dev-libs/libzia-4.72-r1

Description

Platform abstraction code for tucnak package

Added to portage

2026-07-27

mattermost-desktop-bin - 6.3.0_rc2
Ebuild name:

net-im/mattermost-desktop-bin-6.3.0_rc2

Description

Mattermost Desktop application

Added to portage

2026-07-27

nghttp3 - 1.18.0
Ebuild name:

net-libs/nghttp3-1.18.0

Description

HTTP/3 library written in C

Added to portage

2026-07-27

ngtcp2 - 1.25.0
Ebuild name:

net-libs/ngtcp2-1.25.0

Description

Implementation of the IETF QUIC Protocol

Added to portage

2026-07-27

phonenumbers - 9.0.35
Ebuild name:

dev-python/phonenumbers-9.0.35

Description

Python port of Google's libphonenumber

Added to portage

2026-07-27

prompt-toolkit - 3.0.53
Ebuild name:

dev-python/prompt-toolkit-3.0.53

Description

Building powerful interactive command lines in Python

Added to portage

2026-07-27

pygments - 2.20.0
Ebuild name:

dev-python/pygments-2.20.0

Description

Pygments is a syntax highlighting package written in Python

Added to portage

2026-07-27

pyproject-fmt - 2.25.4
Ebuild name:

dev-python/pyproject-fmt-2.25.4

Description

Format your pyproject.toml file

Added to portage

2026-07-27

svxlink - 26.05.1
Ebuild name:

media-radio/svxlink-26.05.1

Description

Multi Purpose Voice Services System, including Qtel for EchoLink

Added to portage

2026-07-27

typeguard - 4.6.0
Ebuild name:

dev-python/typeguard-4.6.0

Description

Run-time type checker for Python

Added to portage

2026-07-27

urwid - 4.0.8
Ebuild name:

dev-python/urwid-4.0.8

Description

Curses-based user interface library for Python

Added to portage

2026-07-27

xephem - 4.2.0-r1
Ebuild name:

sci-astronomy/xephem-4.2.0-r1

Description

Interactive tool for astronomical ephemeris and sky simulation

Added to portage

2026-07-27

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