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:

87912

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-24
dist-kernel - 6.1.184
Ebuild name:

virtual/dist-kernel-6.1.184

Description

Virtual to depend on any Distribution Kernel

Added to portage

2026-08-24

dist-kernel - 6.12.105
Ebuild name:

virtual/dist-kernel-6.12.105

Description

Virtual to depend on any Distribution Kernel

Added to portage

2026-08-24

dist-kernel - 6.18.46
Ebuild name:

virtual/dist-kernel-6.18.46

Description

Virtual to depend on any Distribution Kernel

Added to portage

2026-08-24

dist-kernel - 6.6.153
Ebuild name:

virtual/dist-kernel-6.6.153

Description

Virtual to depend on any Distribution Kernel

Added to portage

2026-08-24

dist-kernel - 7.1.10
Ebuild name:

virtual/dist-kernel-7.1.10

Description

Virtual to depend on any Distribution Kernel

Added to portage

2026-08-24

drumstick - 2.11.1
Ebuild name:

media-sound/drumstick-2.11.1

Description

Qt/C++ wrapper for ALSA sequencer

Added to portage

2026-08-24

evdev - 2.0.0
Ebuild name:

dev-python/evdev-2.0.0

Description

Python library for evdev bindings

Added to portage

2026-08-24

filelock - 3.32.4
Ebuild name:

dev-python/filelock-3.32.4

Description

A platform independent file lock for Python

Added to portage

2026-08-24

gentoo-kernel - 6.1.184
Ebuild name:

sys-kernel/gentoo-kernel-6.1.184

Description

Linux kernel built with Gentoo patches

Added to portage

2026-08-24

gentoo-kernel - 6.12.105
Ebuild name:

sys-kernel/gentoo-kernel-6.12.105

Description

Linux kernel built with Gentoo patches

Added to portage

2026-08-24

gentoo-kernel - 6.18.46
Ebuild name:

sys-kernel/gentoo-kernel-6.18.46

Description

Linux kernel built with Gentoo patches

Added to portage

2026-08-24

gentoo-kernel - 6.6.153
Ebuild name:

sys-kernel/gentoo-kernel-6.6.153

Description

Linux kernel built with Gentoo patches

Added to portage

2026-08-24

gentoo-kernel - 7.1.10
Ebuild name:

sys-kernel/gentoo-kernel-7.1.10

Description

Linux kernel built with Gentoo patches

Added to portage

2026-08-24

gentoo-kernel-bin - 6.1.184
Ebuild name:

sys-kernel/gentoo-kernel-bin-6.1.184

Description

Pre-built Linux kernel with Gentoo patches

Added to portage

2026-08-24

gentoo-kernel-bin - 6.12.105
Ebuild name:

sys-kernel/gentoo-kernel-bin-6.12.105

Description

Pre-built Linux kernel with Gentoo patches

Added to portage

2026-08-24

gentoo-kernel-bin - 6.18.46
Ebuild name:

sys-kernel/gentoo-kernel-bin-6.18.46

Description

Pre-built Linux kernel with Gentoo patches

Added to portage

2026-08-24

gentoo-kernel-bin - 6.6.153
Ebuild name:

sys-kernel/gentoo-kernel-bin-6.6.153

Description

Pre-built Linux kernel with Gentoo patches

Added to portage

2026-08-24

gentoo-kernel-bin - 7.1.10
Ebuild name:

sys-kernel/gentoo-kernel-bin-7.1.10

Description

Pre-built Linux kernel with Gentoo patches

Added to portage

2026-08-24

gentoo-kernel-modprep - 6.1.184
Ebuild name:

sys-kernel/gentoo-kernel-modprep-6.1.184

Description

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

Added to portage

2026-08-24

gentoo-kernel-modprep - 6.12.105
Ebuild name:

sys-kernel/gentoo-kernel-modprep-6.12.105

Description

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

Added to portage

2026-08-24

gentoo-kernel-modprep - 6.18.46
Ebuild name:

sys-kernel/gentoo-kernel-modprep-6.18.46

Description

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

Added to portage

2026-08-24

gentoo-kernel-modprep - 6.6.153
Ebuild name:

sys-kernel/gentoo-kernel-modprep-6.6.153

Description

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

Added to portage

2026-08-24

gentoo-kernel-modprep - 7.1.10
Ebuild name:

sys-kernel/gentoo-kernel-modprep-7.1.10

Description

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

Added to portage

2026-08-24

nh3 - 0.3.7
Ebuild name:

dev-python/nh3-0.3.7

Description

Ammonia HTML sanitizer Python binding

Added to portage

2026-08-24

oct2py - 6.1.1
Ebuild name:

dev-python/oct2py-6.1.1

Description

Python to GNU Octave bridge

Added to portage

2026-08-24

pypdf - 6.16.2
Ebuild name:

dev-python/pypdf-6.16.2

Description

Python library to work with PDF files

Added to portage

2026-08-24

sphinx-autoapi - 3.8.1
Ebuild name:

dev-python/sphinx-autoapi-3.8.1

Description

A new approach to API documentation in Sphinx

Added to portage

2026-08-24

tellico - 4.2.2
Ebuild name:

kde-misc/tellico-4.2.2

Description

Collection manager based on KDE Frameworks

Added to portage

2026-08-24

vanilla-kernel - 6.1.184
Ebuild name:

sys-kernel/vanilla-kernel-6.1.184

Description

Linux kernel built from vanilla upstream sources

Added to portage

2026-08-24

vanilla-kernel - 6.12.105
Ebuild name:

sys-kernel/vanilla-kernel-6.12.105

Description

Linux kernel built from vanilla upstream sources

Added to portage

2026-08-24

vanilla-kernel - 6.18.46
Ebuild name:

sys-kernel/vanilla-kernel-6.18.46

Description

Linux kernel built from vanilla upstream sources

Added to portage

2026-08-24

vanilla-kernel - 6.6.153
Ebuild name:

sys-kernel/vanilla-kernel-6.6.153

Description

Linux kernel built from vanilla upstream sources

Added to portage

2026-08-24

vanilla-kernel - 7.1.10
Ebuild name:

sys-kernel/vanilla-kernel-7.1.10

Description

Linux kernel built from vanilla upstream sources

Added to portage

2026-08-24

xwaylandvideobridge - 0.5.2
Ebuild name:

gui-apps/xwaylandvideobridge-0.5.2

Description

Screenshare Wayland windows to XWayland apps

Added to portage

2026-08-24

2026-08-23
bitwarden-cli-bin - 2026.8.0
Ebuild name:

app-admin/bitwarden-cli-bin-2026.8.0

Description

CLI client for Bitwarden compatible servers

Added to portage

2026-08-23

candy - 6.1.11
Ebuild name:

net-vpn/candy-6.1.11

Description

A reliable, low-latency, and anti-censorship virtual private network

Added to portage

2026-08-23

cloudflared - 2026.8.2
Ebuild name:

net-vpn/cloudflared-2026.8.2

Description

A command-line client and tunneling daemon for Cloudflare Tunnel

Added to portage

2026-08-23

cmd2 - 4.2.1
Ebuild name:

dev-python/cmd2-4.2.1

Description

Extra features for standard library's cmd module

Added to portage

2026-08-23

cudd - 3.0.0-r3
Ebuild name:

sci-mathematics/cudd-3.0.0-r3

Description

Colorado University binary Decision Diagram library

Added to portage

2026-08-23

dsfmt - 2.2.5
Ebuild name:

sci-mathematics/dsfmt-2.2.5

Description

Double precision SIMD-oriented Fast Mersenne Twister library

Added to portage

2026-08-23

fig2dev - 3.2.9a-r1
Ebuild name:

media-gfx/fig2dev-3.2.9a-r1

Description

Set of tools for creating TeX documents with graphics

Added to portage

2026-08-23

filezilla - 3.71.0
Ebuild name:

net-ftp/filezilla-3.71.0

Description

FTP client with lots of useful features and an intuitive interface

Added to portage

2026-08-23

fzssh - 1.4.0
Ebuild name:

net-libs/fzssh-1.4.0

Description

A SSH/SFTP library based on libfilezilla

Added to portage

2026-08-23

gentoo-sources - 6.1.184
Ebuild name:

sys-kernel/gentoo-sources-6.1.184

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-08-23

gentoo-sources - 6.12.105
Ebuild name:

sys-kernel/gentoo-sources-6.12.105

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-08-23

gentoo-sources - 6.18.46
Ebuild name:

sys-kernel/gentoo-sources-6.18.46

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-08-23

gentoo-sources - 6.6.153
Ebuild name:

sys-kernel/gentoo-sources-6.6.153

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-08-23

gentoo-sources - 7.1.10
Ebuild name:

sys-kernel/gentoo-sources-7.1.10

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2026-08-23

ggml - 0.21.0-r1
Ebuild name:

sci-ml/ggml-0.21.0-r1

Description

Tensor library for machine learning

Added to portage

2026-08-23

gitea - 1.27.2
Ebuild name:

www-apps/gitea-1.27.2

Description

A painless self-hosted Git service

Added to portage

2026-08-23

h2o - 2.3.0_pre20260804
Ebuild name:

www-servers/h2o-2.3.0_pre20260804

Description

H2O - the optimized HTTP/1, HTTP/2 server

Added to portage

2026-08-23

labwc - 0.20.2
Ebuild name:

gui-wm/labwc-0.20.2

Description

Openbox alternative for wayland

Added to portage

2026-08-23

lego - 5.4.0
Ebuild name:

app-crypt/lego-5.4.0

Description

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

Added to portage

2026-08-23

libfilezilla - 0.57.0
Ebuild name:

dev-libs/libfilezilla-0.57.0

Description

C++ library offering some basic functionality for platform-independent

Added to portage

2026-08-23

lsp-docker - 1.0.0_p20240327
Ebuild name:

app-emacs/lsp-docker-1.0.0_p20240327

Description

Emacs library to leverage lsp-mode in the Docker environment

Added to portage

2026-08-23

lsp-java - 3.1_p20240328-r1
Ebuild name:

app-emacs/lsp-java-3.1_p20240328-r1

Description

Emacs Java IDE using Eclipse JDT Language Server

Added to portage

2026-08-23

moto - 5.2.3
Ebuild name:

dev-python/moto-5.2.3

Description

Mock library for boto

Added to portage

2026-08-23

pymdown-extensions - 11.0.2
Ebuild name:

dev-python/pymdown-extensions-11.0.2

Description

Extensions for Python Markdown

Added to portage

2026-08-23

ryzen_smu - 0.1.5-r1
Ebuild name:

app-admin/ryzen_smu-0.1.5-r1

Description

Kernel driver for AMD Ryzen's System Management Unit

Added to portage

2026-08-23

s2geometry - 0.13.1-r3
Ebuild name:

sci-geosciences/s2geometry-0.13.1-r3

Description

Computational geometry and spatial indexing on the sphere

Added to portage

2026-08-23

shadowsocks-libev - 3.3.6-r1
Ebuild name:

net-proxy/shadowsocks-libev-3.3.6-r1

Description

A lightweight secured SOCKS5 proxy for embedded devices and lo

Added to portage

2026-08-23

slack - 4.51.191
Ebuild name:

net-im/slack-4.51.191

Description

Team collaboration tool

Added to portage

2026-08-23

smcipmitool - 2.31.0.260727
Ebuild name:

sys-apps/smcipmitool-2.31.0.260727

Description

An out-of-band utility for interfacing with SuperBlade and IPMI

Added to portage

2026-08-23

sqlite - 3.53.4
Ebuild name:

dev-db/sqlite-3.53.4

Description

SQL database engine

Added to portage

2026-08-23

syrupy - 6.0.0
Ebuild name:

dev-python/syrupy-6.0.0

Description

The sweeter pytest snapshot plugin

Added to portage

2026-08-23

telegram-desktop-bin - 7.1.1
Ebuild name:

net-im/telegram-desktop-bin-7.1.1

Description

Official desktop client for Telegram (binary package)

Added to portage

2026-08-23

turbovnc - 3.3.1
Ebuild name:

net-misc/turbovnc-3.3.1

Description

A fast replacement for TigerVNC

Added to portage

2026-08-23

vanilla-sources - 6.1.184
Ebuild name:

sys-kernel/vanilla-sources-6.1.184

Description

Full sources for the Linux kernel

Added to portage

2026-08-23

vanilla-sources - 6.12.105
Ebuild name:

sys-kernel/vanilla-sources-6.12.105

Description

Full sources for the Linux kernel

Added to portage

2026-08-23

vanilla-sources - 6.18.46
Ebuild name:

sys-kernel/vanilla-sources-6.18.46

Description

Full sources for the Linux kernel

Added to portage

2026-08-23

vanilla-sources - 6.6.153
Ebuild name:

sys-kernel/vanilla-sources-6.6.153

Description

Full sources for the Linux kernel

Added to portage

2026-08-23

vanilla-sources - 7.1.10
Ebuild name:

sys-kernel/vanilla-sources-7.1.10

Description

Full sources for the Linux kernel

Added to portage

2026-08-23

vaultwarden - 1.37.2
Ebuild name:

app-admin/vaultwarden-1.37.2

Description

Unofficial Bitwarden compatible password manager

Added to portage

2026-08-23

vaultwarden-web - 2026.7.0
Ebuild name:

www-apps/vaultwarden-web-2026.7.0

Description

Prebuilt web vault frontend for Vaultwarden

Added to portage

2026-08-23

vopono - 0.10.21
Ebuild name:

net-vpn/vopono-0.10.21

Description

Launch applications via VPN tunnels using temporary network namespaces

Added to portage

2026-08-23

wayfire-plugins-extra - 0.11.2
Ebuild name:

gui-libs/wayfire-plugins-extra-0.11.2

Description

extra plugins for wayfire

Added to portage

2026-08-23

wcm - 0.11.0
Ebuild name:

gui-apps/wcm-0.11.0

Description

Wayfire Config Manager

Added to portage

2026-08-23

wf-shell - 0.11.0
Ebuild name:

gui-apps/wf-shell-0.11.0

Description

Compiz like 3D wayland compositor

Added to portage

2026-08-23

wine-staging - 11.16
Ebuild name:

app-emulation/wine-staging-11.16

Description

Free implementation of Windows(tm) on Unix, with Wine-Staging patc

Added to portage

2026-08-23

zellij - 0.45.0
Ebuild name:

app-misc/zellij-0.45.0

Description

A terminal workspace with batteries included

Added to portage

2026-08-23

zfs - 2.2.11
Ebuild name:

sys-fs/zfs-2.2.11

Description

Userland utilities for ZFS Linux kernel module

Added to portage

2026-08-23

zfs - 2.3.9
Ebuild name:

sys-fs/zfs-2.3.9

Description

Userland utilities for ZFS Linux kernel module

Added to portage

2026-08-23

zfs - 2.4.4
Ebuild name:

sys-fs/zfs-2.4.4

Description

Linux kernel module and userland utilities for ZFS

Added to portage

2026-08-23

zfs-kmod - 2.2.11
Ebuild name:

sys-fs/zfs-kmod-2.2.11

Description

Linux ZFS kernel module for sys-fs/zfs

Added to portage

2026-08-23

zfs-kmod - 2.3.9
Ebuild name:

sys-fs/zfs-kmod-2.3.9

Description

Linux ZFS kernel module for sys-fs/zfs

Added to portage

2026-08-23

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