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:

87964

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-08-27
cargo-c - 0.10.25
Ebuild name:

dev-util/cargo-c-0.10.25

Description

Helper program to build and install c-like libraries

Added to portage

2026-08-27

paraview - 6.1.1
Ebuild name:

sci-visualization/paraview-6.1.1

Description

Powerful scientific data visualization application

Added to portage

2026-08-27

spotify - 1.2.96
Ebuild name:

media-sound/spotify-1.2.96

Description

Spotify is a social music platform

Added to portage

2026-08-27

systemd - 261.2
Ebuild name:

sys-apps/systemd-261.2

Description

System and service manager for Linux

Added to portage

2026-08-27

tor - 0.4.9.11-r1
Ebuild name:

net-vpn/tor-0.4.9.11-r1

Description

Anonymizing overlay network for TCP

Added to portage

2026-08-27

2026-08-26
acr38u - 1.7.11-r5
Ebuild name:

app-crypt/acr38u-1.7.11-r5

Description

Non CCID driver for ACR38 AC1038-based Smart Card Reader

Added to portage

2026-08-26

b4 - 0.16.0-r1
Ebuild name:

net-mail/b4-0.16.0-r1

Description

Utility for fetching patchsets from public-inbox

Added to portage

2026-08-26

boto3 - 1.43.80
Ebuild name:

dev-python/boto3-1.43.80

Description

The AWS SDK for Python

Added to portage

2026-08-26

botocore - 1.43.80
Ebuild name:

dev-python/botocore-1.43.80

Description

Low-level, data-driven core of boto 3

Added to portage

2026-08-26

cmd2 - 4.2.2
Ebuild name:

dev-python/cmd2-4.2.2

Description

Extra features for standard library's cmd module

Added to portage

2026-08-26

cramjam - 2.12.1
Ebuild name:

dev-python/cramjam-2.12.1

Description

Thin Python bindings to de/compression algorithms in Rust

Added to portage

2026-08-26

cryptography - 50.0.1
Ebuild name:

dev-python/cryptography-50.0.1

Description

Library providing cryptographic recipes and primitives

Added to portage

2026-08-26

firefox - 154.0.1
Ebuild name:

www-client/firefox-154.0.1

Description

Firefox Web Browser

Added to portage

2026-08-26

firefox-bin - 154.0.1
Ebuild name:

www-client/firefox-bin-154.0.1

Description

Firefox Web Browser

Added to portage

2026-08-26

firefox-l10n - 154.0.1
Ebuild name:

www-client/firefox-l10n-154.0.1

Description

Firefox Web Browser's translation files

Added to portage

2026-08-26

freerdp - 3.31.0
Ebuild name:

net-misc/freerdp-3.31.0

Description

Free implementation of the Remote Desktop Protocol

Added to portage

2026-08-26

gitpython - 3.1.60
Ebuild name:

dev-python/gitpython-3.1.60

Description

Library used to interact with Git repositories

Added to portage

2026-08-26

glibc - 2.43-r4
Ebuild name:

sys-libs/glibc-2.43-r4

Description

GNU libc C library

Added to portage

2026-08-26

glibc - 2.44-r2
Ebuild name:

sys-libs/glibc-2.44-r2

Description

GNU libc C library

Added to portage

2026-08-26

google-api-core - 2.35.0
Ebuild name:

dev-python/google-api-core-2.35.0

Description

Core Library for Google Client Libraries

Added to portage

2026-08-26

google-auth - 2.57.0
Ebuild name:

dev-python/google-auth-2.57.0

Description

Google Authentication Library

Added to portage

2026-08-26

google-auth-httplib2 - 0.4.2
Ebuild name:

dev-python/google-auth-httplib2-0.4.2

Description

httplib2 Transport for Google Auth

Added to portage

2026-08-26

google-auth-oauthlib - 1.4.1
Ebuild name:

dev-python/google-auth-oauthlib-1.4.1

Description

Google Authentication Library

Added to portage

2026-08-26

googleapis-common-protos - 1.75.2
Ebuild name:

dev-python/googleapis-common-protos-1.75.2

Description

Python classes generated from the common protos in the g

Added to portage

2026-08-26

gpxsee - 16.13
Ebuild name:

sci-geosciences/gpxsee-16.13

Description

Viewer and analyzer that supports gpx, tcx, kml, fit, igc and nmea fil

Added to portage

2026-08-26

gssapi - 1.12.0
Ebuild name:

dev-python/gssapi-1.12.0

Description

Low and high level wrappers around the GSSAPI C libraries

Added to portage

2026-08-26

jupyterlab-desktop-bin - 4.6.3.1
Ebuild name:

sci-misc/jupyterlab-desktop-bin-4.6.3.1

Description

JupyterLab desktop application, based on Electron

Added to portage

2026-08-26

libmd - 1.1.0
Ebuild name:

app-crypt/libmd-1.1.0

Description

Message Digest functions from BSD systems

Added to portage

2026-08-26

nbd - 3.27.1
Ebuild name:

sys-block/nbd-3.27.1

Description

Userland client/server for kernel network block device

Added to portage

2026-08-26

nsd - 4.15.1
Ebuild name:

net-dns/nsd-4.15.1

Description

An authoritative only, high performance, open source name server

Added to portage

2026-08-26

openrgb - 1.0_rc3_p1
Ebuild name:

app-misc/openrgb-1.0_rc3_p1

Description

Open source RGB lighting control

Added to portage

2026-08-26

pbr - 7.1.2
Ebuild name:

dev-python/pbr-7.1.2

Description

Inject some useful and sensible default behaviors into setuptools

Added to portage

2026-08-26

pbs-installer - 2026.8.25
Ebuild name:

dev-python/pbs-installer-2026.8.25

Description

Installer for Python Build Standalone

Added to portage

2026-08-26

plotly - 7.0.0
Ebuild name:

dev-python/plotly-7.0.0

Description

Browser-based graphing library for Python

Added to portage

2026-08-26

portalocker - 4.3.0
Ebuild name:

dev-python/portalocker-4.3.0

Description

A library for Python file locking

Added to portage

2026-08-26

proto-plus - 1.28.4
Ebuild name:

dev-python/proto-plus-1.28.4

Description

Beautiful, Pythonic protocol buffers

Added to portage

2026-08-26

pydata-sphinx-theme - 0.21.0
Ebuild name:

dev-python/pydata-sphinx-theme-0.21.0

Description

Bootstrap-based Sphinx theme from the PyData community

Added to portage

2026-08-26

tex4ht - 20240311_p72882-r5
Ebuild name:

dev-tex/tex4ht-20240311_p72882-r5

Description

Converts (La)TeX to (X)HTML, XML and OO.org

Added to portage

2026-08-26

thunderbird-bin - 140.14.1
Ebuild name:

mail-client/thunderbird-bin-140.14.1

Description

Thunderbird Mail Client

Added to portage

2026-08-26

tox - 4.60.1
Ebuild name:

dev-python/tox-4.60.1

Description

virtualenv-based automation of test activities

Added to portage

2026-08-26

urwid - 4.0.13
Ebuild name:

dev-python/urwid-4.0.13

Description

Curses-based user interface library for Python

Added to portage

2026-08-26

uv - 0.12.6
Ebuild name:

dev-python/uv-0.12.6

Description

A Python package installer and resolver, written in Rust

Added to portage

2026-08-26

uv-build - 0.12.6
Ebuild name:

dev-python/uv-build-0.12.6

Description

PEP517 uv build backend

Added to portage

2026-08-26

virtualenv - 21.7.5
Ebuild name:

dev-python/virtualenv-21.7.5

Description

Virtual Python Environment builder

Added to portage

2026-08-26

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