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:

90557

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-23
AusweisApp - 2.6.3
Ebuild name:

sys-auth/AusweisApp-2.6.3

Description

Official authentication app for German ID cards and residence permits

Added to portage

2026-11-23

acme-sh - 3.1.7
Ebuild name:

app-crypt/acme-sh-3.1.7

Description

A pure Unix shell script implementing ACME client protocol

Added to portage

2026-11-23

anope - 2.0.21
Ebuild name:

net-irc/anope-2.0.21

Description

Anope IRC Services

Added to portage

2026-11-23

asio - 1.38.2
Ebuild name:

dev-cpp/asio-1.38.2

Description

Asynchronous Network Library

Added to portage

2026-11-23

aspell - 0.60.8.3
Ebuild name:

app-text/aspell-0.60.8.3

Description

Free and Open Source spell checker designed to replace Ispell

Added to portage

2026-11-23

bear - 4.2.4
Ebuild name:

dev-util/bear-4.2.4

Description

A tool that generates a compilation database for clang tooling

Added to portage

2026-11-23

bedrock-server - 1.26.66.1
Ebuild name:

games-server/bedrock-server-1.26.66.1

Description

The official bedrock (non-java) based server for the sandbox

Added to portage

2026-11-23

dosbox-staging - 0.83.1
Ebuild name:

games-emulation/dosbox-staging-0.83.1

Description

Modernized DOSBox soft-fork

Added to portage

2026-11-23

fheroes2 - 1.1.18
Ebuild name:

games-engines/fheroes2-1.1.18

Description

Recreation of HoMM2 game engine

Added to portage

2026-11-23

inspircd - 4.12.1
Ebuild name:

net-irc/inspircd-4.12.1

Description

Inspire IRCd - The Stable, High-Performance Modular IRCd

Added to portage

2026-11-23

intel-metrics-library - 1.0.249
Ebuild name:

dev-libs/intel-metrics-library-1.0.249

Description

User mode driver helper library that provides access to GPU

Added to portage

2026-11-23

jsoncons - 1.10.0
Ebuild name:

dev-cpp/jsoncons-1.10.0

Description

C++ header-only library for JSON and JSON-like data formats

Added to portage

2026-11-23

kxstitch - 3.0.0
Ebuild name:

media-gfx/kxstitch-3.0.0

Description

Program to create cross stitch patterns

Added to portage

2026-11-23

libupnp - 22.2.4
Ebuild name:

net-libs/libupnp-22.2.4

Description

An Portable Open Source UPnP Development Kit

Added to portage

2026-11-23

mysqltuner - 2.9.4
Ebuild name:

dev-db/mysqltuner-2.9.4

Description

Makes recommendations for increased performance and stability for MySQL

Added to portage

2026-11-23

openrct2 - 0.5.7
Ebuild name:

games-simulation/openrct2-0.5.7

Description

An open source re-implementation of Chris Sawyer's RollerCoaster Ty

Added to portage

2026-11-23

stellarium - 26.3
Ebuild name:

sci-astronomy/stellarium-26.3

Description

3D photo-realistic skies in real time

Added to portage

2026-11-23

strawberry - 1.2.31
Ebuild name:

media-sound/strawberry-1.2.31

Description

Modern music player and library organizer based on Clementine and Qt

Added to portage

2026-11-23

webcamoid - 9.4.0
Ebuild name:

media-video/webcamoid-9.4.0

Description

Full featured webcam capture application

Added to portage

2026-11-23

2026-11-22
aws-sdk-cpp - 1.11.935
Ebuild name:

dev-cpp/aws-sdk-cpp-1.11.935

Description

AWS SDK for C++

Added to portage

2026-11-22

clamav - 1.5.5
Ebuild name:

app-antivirus/clamav-1.5.5

Description

Clam Anti-Virus Scanner

Added to portage

2026-11-22

clang - 24.0.0_pre20261121
Ebuild name:

dev-python/clang-24.0.0_pre20261121

Description

Python bindings for llvm-core/clang

Added to portage

2026-11-22

clang - 24.0.0_pre20261121
Ebuild name:

llvm-core/clang-24.0.0_pre20261121

Description

C language family frontend for LLVM

Added to portage

2026-11-22

clang-common - 24.0.0_pre20261121
Ebuild name:

llvm-core/clang-common-24.0.0_pre20261121

Description

Common files shared between multiple slots of clang

Added to portage

2026-11-22

cmdliner - 2.1.1
Ebuild name:

dev-ml/cmdliner-2.1.1

Description

Declarative definition of command line interfaces for OCaml

Added to portage

2026-11-22

compiler-rt - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/compiler-rt-24.0.0_pre20261121

Description

Compiler runtime library for clang (built-in part)

Added to portage

2026-11-22

compiler-rt-sanitizers - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/compiler-rt-sanitizers-24.0.0_pre20261121

Description

Compiler runtime libraries for clang (sanit

Added to portage

2026-11-22

corkscrew - 3.1
Ebuild name:

net-vpn/corkscrew-3.1

Description

Tool for tunneling SSH through HTTP proxies

Added to portage

2026-11-22

cypari2 - 2.2.9
Ebuild name:

dev-python/cypari2-2.2.9

Description

Cython interface to PARI

Added to portage

2026-11-22

diffoscope - 339
Ebuild name:

dev-util/diffoscope-339

Description

Will try to get to the bottom of what makes files or directories different

Added to portage

2026-11-22

eid-mw - 5.2.2
Ebuild name:

app-crypt/eid-mw-5.2.2

Description

Electronic Identity Card middleware supplied by the Belgian Federal Governme

Added to portage

2026-11-22

flang - 24.0.0_pre20261121
Ebuild name:

llvm-core/flang-24.0.0_pre20261121

Description

LLVM's Fortran frontend

Added to portage

2026-11-22

flang-rt - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/flang-rt-24.0.0_pre20261121

Description

LLVM's Fortran runtime

Added to portage

2026-11-22

getdata - 0.12.0
Ebuild name:

sci-libs/getdata-0.12.0

Description

Reference implementation of the Dirfile, format for time-ordered binary dat

Added to portage

2026-11-22

gitolite - 3.6.15
Ebuild name:

dev-vcs/gitolite-3.6.15

Description

Highly flexible server for git directory version tracker

Added to portage

2026-11-22

google-auth - 2.63.1
Ebuild name:

dev-python/google-auth-2.63.1

Description

Google Authentication Library

Added to portage

2026-11-22

grafana-bin - 13.3.1
Ebuild name:

www-apps/grafana-bin-13.3.1

Description

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

Added to portage

2026-11-22

grub-xen-host - 1.0-r3
Ebuild name:

app-emulation/grub-xen-host-1.0-r3

Description

Grub2 built as a PV grub per the Xen PV Boot Protocol

Added to portage

2026-11-22

hplip - 3.26.6-r1
Ebuild name:

net-print/hplip-3.26.6-r1

Description

HP Linux Imaging and Printing - Print, scan, fax drivers and service tool

Added to portage

2026-11-22

jingoo - 1.5.4
Ebuild name:

dev-ml/jingoo-1.5.4

Description

OCaml template engine almost compatible with Jinja2

Added to portage

2026-11-22

khal - 0.14.1
Ebuild name:

app-misc/khal-0.14.1

Description

A CalDAV based calendar

Added to portage

2026-11-22

knowit - 0.8.0
Ebuild name:

dev-python/knowit-0.8.0

Description

Know better your media files

Added to portage

2026-11-22

libclc - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/libclc-24.0.0_pre20261121

Description

OpenCL C library

Added to portage

2026-11-22

libcxx - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/libcxx-24.0.0_pre20261121

Description

New implementation of the C++ standard library, targeting C

Added to portage

2026-11-22

libcxxabi - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/libcxxabi-24.0.0_pre20261121

Description

Low level support for a standard C++ library

Added to portage

2026-11-22

libgcc - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/libgcc-24.0.0_pre20261121

Description

Compiler runtime library for clang, compatible with libgcc_

Added to portage

2026-11-22

libtmux - 0.64.0
Ebuild name:

dev-python/libtmux-0.64.0

Description

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

Added to portage

2026-11-22

libunwind - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/libunwind-24.0.0_pre20261121

Description

C++ runtime stack unwinder from LLVM

Added to portage

2026-11-22

lit - 24.0.0_pre20261121
Ebuild name:

dev-python/lit-24.0.0_pre20261121

Description

A stand-alone install of the LLVM suite testing tool

Added to portage

2026-11-22

lld - 24.0.0_pre20261121
Ebuild name:

llvm-core/lld-24.0.0_pre20261121

Description

The LLVM linker (link editor)

Added to portage

2026-11-22

lldb - 24.0.0_pre20261121
Ebuild name:

llvm-core/lldb-24.0.0_pre20261121

Description

The LLVM debugger

Added to portage

2026-11-22

llvm - 24.0.0_pre20261121
Ebuild name:

dev-ml/llvm-24.0.0_pre20261121

Description

OCaml bindings for LLVM

Added to portage

2026-11-22

llvm - 24.0.0_pre20261121
Ebuild name:

llvm-core/llvm-24.0.0_pre20261121

Description

Low Level Virtual Machine

Added to portage

2026-11-22

llvm-common - 24.0.0_pre20261121
Ebuild name:

llvm-core/llvm-common-24.0.0_pre20261121

Description

Common files shared between multiple slots of LLVM

Added to portage

2026-11-22

mechanize - 0.4.11
Ebuild name:

dev-python/mechanize-0.4.11

Description

Stateful programmatic web browsing in Python

Added to portage

2026-11-22

mgorny-dev-scripts - 91
Ebuild name:

app-portage/mgorny-dev-scripts-91

Description

Handy scripts for ebuild development and more

Added to portage

2026-11-22

mlir - 24.0.0_pre20261121
Ebuild name:

llvm-core/mlir-24.0.0_pre20261121

Description

Multi-Level Intermediate Representation (library only)

Added to portage

2026-11-22

mpd - 0.24.20
Ebuild name:

media-sound/mpd-0.24.20

Description

The Music Player Daemon (mpd)

Added to portage

2026-11-22

netqmail - 1.06-r18
Ebuild name:

mail-mta/netqmail-1.06-r18

Description

qmail -- a secure, reliable, efficient, simple message transfer agent

Added to portage

2026-11-22

oauth2-proxy - 7.15.6
Ebuild name:

net-proxy/oauth2-proxy-7.15.6

Description

Reverse proxy that provides authentication with many identity provide

Added to portage

2026-11-22

obs-studio - 33.0.2
Ebuild name:

media-video/obs-studio-33.0.2

Description

Software for Recording and Streaming Live Video Content

Added to portage

2026-11-22

ollama - 0.40.17
Ebuild name:

sci-ml/ollama-0.40.17

Description

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

Added to portage

2026-11-22

openmp - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/openmp-24.0.0_pre20261121

Description

OpenMP runtime libraries for LLVM/clang compiler

Added to portage

2026-11-22

openmp-amdgcn-amd-amdhsa - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/openmp-amdgcn-amd-amdhsa-24.0.0_pre20261121

Description

OpenMP target library for amdgcn devices

Added to portage

2026-11-22

openmp-nvptx64-nvidia-cuda - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/openmp-nvptx64-nvidia-cuda-24.0.0_pre20261121

Description

OpenMP target library for nvptx64 devic

Added to portage

2026-11-22

openmp-spirv64-intel - 24.0.0_pre20261121
Ebuild name:

llvm-runtimes/openmp-spirv64-intel-24.0.0_pre20261121

Description

OpenMP target library for spirv64 Intel devic

Added to portage

2026-11-22

optint - 0.3.1
Ebuild name:

dev-ml/optint-0.3.1

Description

Efficient integer types on 64-bit architectures

Added to portage

2026-11-22

pari - 2.19.1
Ebuild name:

sci-mathematics/pari-2.19.1

Description

Computer-aided number theory C library and tools

Added to portage

2026-11-22

poetry - 2.5.2
Ebuild name:

dev-python/poetry-2.5.2

Description

A frontend for poetry - a python dependency management and packaging tool

Added to portage

2026-11-22

poetry-plugin-export - 1.10.2
Ebuild name:

dev-python/poetry-plugin-export-1.10.2

Description

A plugin that allows the export of locked packages to variou

Added to portage

2026-11-22

polly - 24.0.0_pre20261121
Ebuild name:

llvm-core/polly-24.0.0_pre20261121

Description

Polyhedral optimizations for LLVM

Added to portage

2026-11-22

ppx_deriving - 6.2.0
Ebuild name:

dev-ml/ppx_deriving-6.2.0

Description

Type-driven code generation for OCaml

Added to portage

2026-11-22

ppx_import - 1.12.0-r2
Ebuild name:

dev-ml/ppx_import-1.12.0-r2

Description

A syntax extension for importing declarations from interface files

Added to portage

2026-11-22

ppx_import - 1.13.0
Ebuild name:

dev-ml/ppx_import-1.13.0

Description

A syntax extension for importing declarations from interface files

Added to portage

2026-11-22

rust - 1.99.1
Ebuild name:

dev-lang/rust-1.99.1

Description

Systems programming language originally developed by Mozilla

Added to portage

2026-11-22

rust-bin - 1.99.1
Ebuild name:

dev-lang/rust-bin-1.99.1

Description

Added to portage

2026-11-22

rust-common - 1.99.1
Ebuild name:

dev-lang/rust-common-1.99.1

Description

Common files shared between multiple slots of Rust

Added to portage

2026-11-22

rust-std - 1.99.1
Ebuild name:

sys-devel/rust-std-1.99.1

Description

Rust standard library, standalone (for crossdev)

Added to portage

2026-11-22

sedlex - 3.8.1
Ebuild name:

dev-ml/sedlex-3.8.1

Description

Added to portage

2026-11-22

spacenavd - 1.4-r2
Ebuild name:

app-misc/spacenavd-1.4-r2

Description

The spacenavd daemon provides free alternative to the 3dxserv daemon

Added to portage

2026-11-22

supertux - 0.7.0.1
Ebuild name:

games-arcade/supertux-0.7.0.1

Description

A run 'n jump platforming game featuring Tux the penguin

Added to portage

2026-11-22

syrupy - 7.0.3
Ebuild name:

dev-python/syrupy-7.0.3

Description

The sweeter pytest snapshot plugin

Added to portage

2026-11-22

sysstat - 12.8.1
Ebuild name:

app-admin/sysstat-12.8.1

Description

System performance tools for Linux

Added to portage

2026-11-22

trimesh - 5.2.2
Ebuild name:

dev-python/trimesh-5.2.2

Description

Python library for loading and using triangular meshes

Added to portage

2026-11-22

virtualenv - 21.15.12
Ebuild name:

dev-python/virtualenv-21.15.12

Description

Virtual Python Environment builder

Added to portage

2026-11-22

watchdog - 7.1.1
Ebuild name:

dev-python/watchdog-7.1.1

Description

Python API and shell utilities to monitor file system events

Added to portage

2026-11-22

wcwidth - 0.9.5
Ebuild name:

dev-python/wcwidth-0.9.5

Description

Measures number of Terminal column cells of wide-character codes

Added to portage

2026-11-22

wgetpaste - 2.34-r1
Ebuild name:

app-text/wgetpaste-2.34-r1

Description

Command-line interface to various pastebins

Added to portage

2026-11-22

xfce4-dev-tools - 4.21.3
Ebuild name:

dev-build/xfce4-dev-tools-4.21.3

Description

A set of scripts and m4/autoconf macros that ease build system mai

Added to portage

2026-11-22

ytnef - 2.1.5
Ebuild name:

net-mail/ytnef-2.1.5

Description

Yeraze's TNEF Stream Reader - for winmail.dat files

Added to portage

2026-11-22

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