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:

82799

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-01-13
devcontainer - 0.81.0
Ebuild name:

app-containers/devcontainer-0.81.0

Description

Reference implementation of the Development Containers specifica

Added to portage

2026-01-13

dotnet-outdated - 4.6.9
Ebuild name:

dev-dotnet/dotnet-outdated-4.6.9

Description

Display and update outdated NuGet packages in a project

Added to portage

2026-01-13

kdevelop - 25.08.3-r1
Ebuild name:

dev-util/kdevelop-25.08.3-r1

Description

Integrated Development Environment, supporting KF6/Qt, C/C++ and much

Added to portage

2026-01-13

osm - 2.1
Ebuild name:

app-emacs/osm-2.1

Description

OpenStreetMap tile-based viewer for GNU Emacs

Added to portage

2026-01-13

2026-01-12
binary-orphans - 1.0.5
Ebuild name:

dev-haskell/binary-orphans-1.0.5

Description

Compatibility package for binary; provides instances

Added to portage

2026-01-12

bitvec - 1.1.5.0
Ebuild name:

dev-haskell/bitvec-1.1.5.0

Description

Space-efficient bit vectors

Added to portage

2026-01-12

boost - 1.90.0
Ebuild name:

dev-libs/boost-1.90.0

Description

Boost Libraries for C++

Added to portage

2026-01-12

busybox - 1.36.1-r4
Ebuild name:

sys-apps/busybox-1.36.1-r4

Description

Utilities for rescue and embedded systems

Added to portage

2026-01-12

calligraplan - 4.0.1
Ebuild name:

app-office/calligraplan-4.0.1

Description

Project management application

Added to portage

2026-01-12

chell - 0.5.0.2-r1
Ebuild name:

dev-haskell/chell-0.5.0.2-r1

Description

A simple and intuitive library for automated testing

Added to portage

2026-01-12

dalli - 4.0.0
Ebuild name:

dev-ruby/dalli-4.0.0

Description

A high performance pure Ruby client for accessing memcached servers

Added to portage

2026-01-12

darcs - 2.16.5-r6
Ebuild name:

dev-vcs/darcs-2.16.5-r6

Description

a distributed, interactive, smart revision control system

Added to portage

2026-01-12

dulwich - 0.25.2
Ebuild name:

dev-python/dulwich-0.25.2

Description

Pure-Python implementation of the Git file formats and protocols

Added to portage

2026-01-12

fastfetch - 2.57.0
Ebuild name:

app-misc/fastfetch-2.57.0

Description

Fast neofetch-like system information tool

Added to portage

2026-01-12

firefox-bin - 147.0
Ebuild name:

www-client/firefox-bin-147.0

Description

Firefox Web Browser

Added to portage

2026-01-12

gcc - 14.3.1_p20260109
Ebuild name:

sys-devel/gcc-14.3.1_p20260109

Description

The GNU Compiler Collection

Added to portage

2026-01-12

gcc - 15.2.1_p20260110
Ebuild name:

sys-devel/gcc-15.2.1_p20260110

Description

The GNU Compiler Collection

Added to portage

2026-01-12

gcc - 16.0.0_p20260111
Ebuild name:

sys-devel/gcc-16.0.0_p20260111

Description

The GNU Compiler Collection

Added to portage

2026-01-12

git - 4.2.0
Ebuild name:

dev-ruby/git-4.2.0

Description

Library for using Git in Ruby

Added to portage

2026-01-12

git-sources - 6.19_rc5
Ebuild name:

sys-kernel/git-sources-6.19_rc5

Description

The very latest -git version of the Linux kernel

Added to portage

2026-01-12

hishel - 1.1.8
Ebuild name:

dev-python/hishel-1.1.8

Description

An elegant HTTP Cache implementation for HTTPX and HTTP Core

Added to portage

2026-01-12

hypothesis - 6.150.1
Ebuild name:

dev-python/hypothesis-6.150.1

Description

A library for property based testing

Added to portage

2026-01-12

ig - 0.48.0
Ebuild name:

app-admin/ig-0.48.0

Description

Tools and framework for data collection and system inspection using eBPF

Added to portage

2026-01-12

inkscape - 1.4.3
Ebuild name:

media-gfx/inkscape-1.4.3

Description

SVG based generic vector-drawing program

Added to portage

2026-01-12

jupyterlab - 4.5.2
Ebuild name:

dev-python/jupyterlab-4.5.2

Description

JupyterLab computational environment

Added to portage

2026-01-12

kdevelop - 25.12.1-r1
Ebuild name:

dev-util/kdevelop-25.12.1-r1

Description

Integrated Development Environment, supporting KF6/Qt, C/C++ and much

Added to portage

2026-01-12

kube-apiserver - 1.34.3
Ebuild name:

sys-cluster/kube-apiserver-1.34.3

Description

Kubernetes API server

Added to portage

2026-01-12

kube-controller-manager - 1.34.3
Ebuild name:

sys-cluster/kube-controller-manager-1.34.3

Description

Kubernetes Controller Manager

Added to portage

2026-01-12

kube-proxy - 1.34.3
Ebuild name:

sys-cluster/kube-proxy-1.34.3

Description

Kubernetes Proxy service

Added to portage

2026-01-12

kube-scheduler - 1.34.3
Ebuild name:

sys-cluster/kube-scheduler-1.34.3

Description

Kubernetes Scheduler

Added to portage

2026-01-12

kubeadm - 1.34.3
Ebuild name:

sys-cluster/kubeadm-1.34.3

Description

CLI to Easily bootstrap a secure Kubernetes cluster

Added to portage

2026-01-12

kubectl - 1.34.3
Ebuild name:

sys-cluster/kubectl-1.34.3

Description

CLI to run commands against Kubernetes clusters

Added to portage

2026-01-12

kubelet - 1.34.3
Ebuild name:

sys-cluster/kubelet-1.34.3

Description

Kubernetes Node Agent

Added to portage

2026-01-12

leancheck - 1.0.4
Ebuild name:

dev-haskell/leancheck-1.0.4

Description

Enumerative property-based testing

Added to portage

2026-01-12

lego - 4.31.0
Ebuild name:

app-crypt/lego-4.31.0

Description

Let's Encrypt/ACME client (like certbot or acme.sh) and library written in Go

Added to portage

2026-01-12

libtasn1 - 4.21.0
Ebuild name:

dev-libs/libtasn1-4.21.0

Description

ASN.1 library

Added to portage

2026-01-12

linux-firmware - 20260110
Ebuild name:

sys-kernel/linux-firmware-20260110

Description

Linux firmware files

Added to portage

2026-01-12

localhost - 1.7.0
Ebuild name:

dev-ruby/localhost-1.7.0

Description

Manage a local CA for self-signed localhost development servers

Added to portage

2026-01-12

notebook - 7.5.2
Ebuild name:

dev-python/notebook-7.5.2

Description

Jupyter Interactive Notebook

Added to portage

2026-01-12

onetuple - 0.4.2.1
Ebuild name:

dev-haskell/onetuple-0.4.2.1

Description

Singleton Tuple

Added to portage

2026-01-12

openpgp-keys-gentoo-developers - 20260105
Ebuild name:

sec-keys/openpgp-keys-gentoo-developers-20260105

Description

Gentoo Authority Keys (GLEP 79)

Added to portage

2026-01-12

openpgp-keys-libtasn1 - 20260112
Ebuild name:

sec-keys/openpgp-keys-libtasn1-20260112

Description

OpenPGP keys used by GNU Libtasn1

Added to portage

2026-01-12

pcsx2 - 2.6.2
Ebuild name:

games-emulation/pcsx2-2.6.2

Description

PlayStation 2 emulator

Added to portage

2026-01-12

regex-base - 0.94.0.3
Ebuild name:

dev-haskell/regex-base-0.94.0.3

Description

Common

Added to portage

2026-01-12

regex-posix - 0.96.0.2
Ebuild name:

dev-haskell/regex-posix-0.96.0.2

Description

POSIX Backend for

Added to portage

2026-01-12

regex-tdfa - 1.3.2.5
Ebuild name:

dev-haskell/regex-tdfa-1.3.2.5

Description

Pure Haskell Tagged DFA Backend for

Added to portage

2026-01-12

ruby-cairo-gobject - 4.3.4
Ebuild name:

dev-ruby/ruby-cairo-gobject-4.3.4

Description

Ruby cairo-gobject bindings

Added to portage

2026-01-12

ruby-gio2 - 4.3.4-r1
Ebuild name:

dev-ruby/ruby-gio2-4.3.4-r1

Description

Ruby binding of gio-2

Added to portage

2026-01-12

ruby-glib2 - 4.3.4-r1
Ebuild name:

dev-ruby/ruby-glib2-4.3.4-r1

Description

Ruby Glib2 bindings

Added to portage

2026-01-12

ruby-gobject-introspection - 4.3.4-r1
Ebuild name:

dev-ruby/ruby-gobject-introspection-4.3.4-r1

Description

Ruby GObjectIntrospection bindings

Added to portage

2026-01-12

ruby-poppler - 4.3.4
Ebuild name:

dev-ruby/ruby-poppler-4.3.4

Description

Ruby poppler-glib bindings

Added to portage

2026-01-12

ruff - 0.14.11
Ebuild name:

dev-util/ruff-0.14.11

Description

An extremely fast Python linter, written in Rust

Added to portage

2026-01-12

scdrand - 0.3.5
Ebuild name:

app-crypt/scdrand-0.3.5

Description

Feed kernel entropy pool from smartcard's TRNG

Added to portage

2026-01-12

subrandr - 1.1.0
Ebuild name:

media-libs/subrandr-1.1.0

Description

Subtitle rendering library for rendering non-ASS subtitles

Added to portage

2026-01-12

system-fileio - 0.3.16.7
Ebuild name:

dev-haskell/system-fileio-0.3.16.7

Description

Consistent filesystem interaction across GHC versions (deprecate

Added to portage

2026-01-12

systemd - 259
Ebuild name:

sys-apps/systemd-259

Description

System and service manager for Linux

Added to portage

2026-01-12

telegram-desktop - 6.4.2
Ebuild name:

net-im/telegram-desktop-6.4.2

Description

Official desktop client for Telegram

Added to portage

2026-01-12

telegram-desktop-bin - 6.4.2
Ebuild name:

net-im/telegram-desktop-bin-6.4.2

Description

Official desktop client for Telegram (binary package)

Added to portage

2026-01-12

test-framework - 0.8.2.3
Ebuild name:

dev-haskell/test-framework-0.8.2.3

Description

Framework for running and organising tests, with HUnit and Quick

Added to portage

2026-01-12

test-framework-hunit - 0.3.0.3
Ebuild name:

dev-haskell/test-framework-hunit-0.3.0.3

Description

HUnit support for the test-framework package

Added to portage

2026-01-12

test-framework-leancheck - 0.0.4
Ebuild name:

dev-haskell/test-framework-leancheck-0.0.4

Description

LeanCheck support for test-framework

Added to portage

2026-01-12

test-framework-quickcheck2 - 0.3.0.7
Ebuild name:

dev-haskell/test-framework-quickcheck2-0.3.0.7

Description

QuickCheck-2 support for the test-framework package

Added to portage

2026-01-12

trove-classifiers - 2026.1.12.15
Ebuild name:

dev-python/trove-classifiers-2026.1.12.15

Description

Canonical source for classifiers on PyPI (pypi.org)

Added to portage

2026-01-12

unifont - 17.0.03
Ebuild name:

media-fonts/unifont-17.0.03

Description

GNU Unifont - a Pan-Unicode X11 bitmap iso10646 font

Added to portage

2026-01-12

whenever - 0.9.5
Ebuild name:

dev-python/whenever-0.9.5

Description

Modern datetime library for Python

Added to portage

2026-01-12

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