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:

90085

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-10
bacula - 15.0.3-r4
Ebuild name:

app-backup/bacula-15.0.3-r4

Description

Featureful client/server network backup suite

Added to portage

2026-11-10

c-blosc2 - 3.6.0
Ebuild name:

dev-libs/c-blosc2-3.6.0

Description

Blocking, shuffling and lossless compression library

Added to portage

2026-11-10

courier-imap - 6.0.8
Ebuild name:

net-mail/courier-imap-6.0.8

Description

An IMAP daemon designed specifically for maildirs

Added to portage

2026-11-10

croniter - 7.0.0
Ebuild name:

dev-python/croniter-7.0.0

Description

Python module to provide iteration for datetime object

Added to portage

2026-11-10

ebuild-mode - 1.90
Ebuild name:

app-xemacs/ebuild-mode-1.90

Description

Emacs modes for editing ebuilds and other Gentoo specific files

Added to portage

2026-11-10

firefox - 160.0
Ebuild name:

www-client/firefox-160.0

Description

Firefox Web Browser

Added to portage

2026-11-10

firefox-bin - 160.0
Ebuild name:

www-client/firefox-bin-160.0

Description

Firefox Web Browser

Added to portage

2026-11-10

firefox-l10n - 160.0
Ebuild name:

www-client/firefox-l10n-160.0

Description

Firefox Web Browser's translation files

Added to portage

2026-11-10

gammu - 1.45.2
Ebuild name:

app-mobilephone/gammu-1.45.2

Description

A tool to handle your cellular phone

Added to portage

2026-11-10

gentoo-rsync-mirror - 1.0-r7
Ebuild name:

app-admin/gentoo-rsync-mirror-1.0-r7

Description

Ebuild for setting up a Gentoo rsync mirror

Added to portage

2026-11-10

ggml - 0.29.0-r1
Ebuild name:

sci-ml/ggml-0.29.0-r1

Description

Tensor library for machine learning

Added to portage

2026-11-10

importlib-metadata - 10.2.0
Ebuild name:

dev-python/importlib-metadata-10.2.0

Description

Read metadata from Python packages

Added to portage

2026-11-10

inline-snapshot - 0.36.2
Ebuild name:

dev-python/inline-snapshot-0.36.2

Description

Create and update inline snapshots in your Python tests

Added to portage

2026-11-10

inotify-tools - 4.26.275
Ebuild name:

sys-fs/inotify-tools-4.26.275

Description

Set of command-line programs providing a simple interface to inotify

Added to portage

2026-11-10

intellij-idea - 2026.3-r2
Ebuild name:

dev-util/intellij-idea-2026.3-r2

Description

A complete toolset for web, mobile and enterprise development

Added to portage

2026-11-10

jsoup - 1.24.1
Ebuild name:

dev-java/jsoup-1.24.1

Description

Java HTML parser that makes sense of real-world HTML soup

Added to portage

2026-11-10

keywiz - 1.4
Ebuild name:

app-emacs/keywiz-1.4

Description

Emacs key sequence quiz

Added to portage

2026-11-10

kind-icon - 0.2.2
Ebuild name:

app-emacs/kind-icon-0.2.2

Description

Completion kind icons

Added to portage

2026-11-10

kirigami - 1.2.3
Ebuild name:

app-emacs/kirigami-1.2.3

Description

A unified method to fold and unfold text

Added to portage

2026-11-10

lazy-importer - 0.1.0
Ebuild name:

dev-python/lazy-importer-0.1.0

Description

A context manager for portable, opt-in lazy imports

Added to portage

2026-11-10

lean-mode - 0_p20230611-r1
Ebuild name:

app-emacs/lean-mode-0_p20230611-r1

Description

Emacs mode for the Lean 3 theorem prover

Added to portage

2026-11-10

libxslt - 1.1.45-r1
Ebuild name:

dev-libs/libxslt-1.1.45-r1

Description

XSLT libraries and tools

Added to portage

2026-11-10

lz4 - 1.11.1
Ebuild name:

app-arch/lz4-1.11.1

Description

Extremely Fast Compression algorithm

Added to portage

2026-11-10

lzma - 26.06
Ebuild name:

dev-java/lzma-26.06

Description

Java code for LZMA compression and decompression

Added to portage

2026-11-10

ollama - 0.40.16
Ebuild name:

sci-ml/ollama-0.40.16

Description

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

Added to portage

2026-11-10

openjdk-bin - 11.0.33_p10
Ebuild name:

dev-java/openjdk-bin-11.0.33_p10

Description

Prebuilt Java JDK binaries provided by Eclipse Temurin

Added to portage

2026-11-10

openjdk-jre-bin - 11.0.33_p10
Ebuild name:

dev-java/openjdk-jre-bin-11.0.33_p10

Description

Prebuilt Java JRE binaries provided by Eclipse Temurin

Added to portage

2026-11-10

openjdk-jre-bin - 8.512_p09
Ebuild name:

dev-java/openjdk-jre-bin-8.512_p09

Description

Prebuilt Java JRE binaries provided by Eclipse Temurin

Added to portage

2026-11-10

perf - 7.3
Ebuild name:

dev-util/perf-7.3

Description

Userland tools for Linux Performance Counters

Added to portage

2026-11-10

piwigo - 16.5.0
Ebuild name:

www-apps/piwigo-16.5.0

Description

a photo gallery software for the web

Added to portage

2026-11-10

pymysql - 1.2.4
Ebuild name:

dev-python/pymysql-1.2.4

Description

Pure-Python MySQL Driver

Added to portage

2026-11-10

qtbase - 6.11.3-r1
Ebuild name:

dev-qt/qtbase-6.11.3-r1

Description

Cross-platform application development framework

Added to portage

2026-11-10

sigil - 2.8.6
Ebuild name:

app-text/sigil-2.8.6

Description

Multi-platform WYSIWYG ebook editor for ePub format

Added to portage

2026-11-10

simpleagenda - 0.50
Ebuild name:

gnustep-apps/simpleagenda-0.50

Description

a simple calendar and agenda application

Added to portage

2026-11-10

soupsieve - 4.1
Ebuild name:

dev-python/soupsieve-4.1

Description

A modern CSS selector implementation for BeautifulSoup

Added to portage

2026-11-10

tornado - 6.6.1
Ebuild name:

dev-python/tornado-6.6.1

Description

Python web framework and asynchronous networking library

Added to portage

2026-11-10

typer - 0.29.0
Ebuild name:

dev-python/typer-0.29.0

Description

Build great CLIs. Easy to code. Based on Python type hints

Added to portage

2026-11-10

ueberzugpp - 2.9.11
Ebuild name:

media-gfx/ueberzugpp-2.9.11

Description

Drop in replacement for ueberzug written in C++

Added to portage

2026-11-10

xxhash - 0.8.4
Ebuild name:

dev-libs/xxhash-0.8.4

Description

Extremely fast non-cryptographic hash algorithm

Added to portage

2026-11-10

xxhash - 4.1.0
Ebuild name:

dev-python/xxhash-4.1.0

Description

Python binding for the xxHash library

Added to portage

2026-11-10

2026-11-09
7zip - 26.06
Ebuild name:

app-arch/7zip-26.06

Description

Free file archiver for extremely high compression

Added to portage

2026-11-09

apprise - 2.2.0
Ebuild name:

dev-python/apprise-2.2.0

Description

Push Notifications that work with just about every platform

Added to portage

2026-11-09

caddy - 2.11.9
Ebuild name:

www-servers/caddy-2.11.9

Description

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HT

Added to portage

2026-11-09

coinor-cbc - 2.10.12-r2
Ebuild name:

sci-libs/coinor-cbc-2.10.12-r2

Description

COIN-OR branch-and-cut mixed integer program solver

Added to portage

2026-11-09

coinor-cbc - 2.10.5-r2
Ebuild name:

sci-libs/coinor-cbc-2.10.5-r2

Description

COIN-OR branch-and-cut mixed integer program solver

Added to portage

2026-11-09

coinor-clp - 1.17.10-r1
Ebuild name:

sci-libs/coinor-clp-1.17.10-r1

Description

COIN-OR linear programming solver

Added to portage

2026-11-09

coinor-clp - 1.17.6-r2
Ebuild name:

sci-libs/coinor-clp-1.17.6-r2

Description

COIN-OR linear programming solver

Added to portage

2026-11-09

gcc - 17.0.0_p20261108
Ebuild name:

sys-devel/gcc-17.0.0_p20261108

Description

The GNU Compiler Collection

Added to portage

2026-11-09

git-sources - 7.4_rc2
Ebuild name:

sys-kernel/git-sources-7.4_rc2

Description

The very latest -git version of the Linux kernel

Added to portage

2026-11-09

gsoap - 2.8.130-r2
Ebuild name:

net-libs/gsoap-2.8.130-r2

Description

A cross-platform open source C and C++ SDK for SOAP/XML Web services

Added to portage

2026-11-09

headscale - 0.29.7
Ebuild name:

net-vpn/headscale-0.29.7

Description

An open source, self-hosted implementation of the Tailscale control server

Added to portage

2026-11-09

kmscon - 10.1.1
Ebuild name:

sys-apps/kmscon-10.1.1

Description

KMS/DRM based virtual Console Emulator

Added to portage

2026-11-09

ldl - 2.2.6-r1
Ebuild name:

sci-libs/ldl-2.2.6-r1

Description

Simple but educational LDL^T matrix factorization algorithm

Added to portage

2026-11-09

ledger-mode - 4.0.0
Ebuild name:

app-emacs/ledger-mode-4.0.0

Description

An Emacs major mode for editing ledger files

Added to portage

2026-11-09

libmd - 1.2.0
Ebuild name:

app-crypt/libmd-1.2.0

Description

Message Digest functions from BSD systems

Added to portage

2026-11-09

libmd - 1.3.0
Ebuild name:

app-crypt/libmd-1.3.0

Description

Message Digest functions from BSD systems

Added to portage

2026-11-09

lice-el - 0.3
Ebuild name:

app-emacs/lice-el-0.3

Description

License and header template for GNU Emacs

Added to portage

2026-11-09

nuitka - 4.3.5
Ebuild name:

dev-python/nuitka-4.3.5

Description

Python to native compiler

Added to portage

2026-11-09

pkixssh - 20.1
Ebuild name:

net-misc/pkixssh-20.1

Description

OpenSSH fork with X.509 v3 certificate support

Added to portage

2026-11-09

pymdown-extensions - 13.0
Ebuild name:

dev-python/pymdown-extensions-13.0

Description

Extensions for Python Markdown

Added to portage

2026-11-09

pypiserver - 2.4.3
Ebuild name:

dev-python/pypiserver-2.4.3

Description

Minimal PyPI server

Added to portage

2026-11-09

pyside - 6.12.0-r1
Ebuild name:

dev-python/pyside-6.12.0-r1

Description

Python bindings for the Qt framework

Added to portage

2026-11-09

pytest-xdist - 3.8.0-r1
Ebuild name:

dev-python/pytest-xdist-3.8.0-r1

Description

Distributed testing and loop-on-failing modes

Added to portage

2026-11-09

regex - 2026.11.9
Ebuild name:

dev-python/regex-2026.11.9

Description

Alternative regular expression module to replace re

Added to portage

2026-11-09

smb4k - 4.0.8
Ebuild name:

net-misc/smb4k-4.0.8

Description

Advanced network neighborhood browser

Added to portage

2026-11-09

snapd - 2.63-r1
Ebuild name:

app-containers/snapd-2.63-r1

Description

Service and tools for management of snap packages

Added to portage

2026-11-09

tifffile - 2026.11.8
Ebuild name:

dev-python/tifffile-2026.11.8

Description

Read and write TIFF files

Added to portage

2026-11-09

tree-sitter - 0.26.1
Ebuild name:

dev-python/tree-sitter-0.26.1

Description

Python bindings to the Tree-sitter parsing library

Added to portage

2026-11-09

tvheadend - 4.3_p20261106
Ebuild name:

media-tv/tvheadend-4.3_p20261106

Description

Tvheadend is a TV streaming server and digital video recorder

Added to portage

2026-11-09

uhd - 4.11.0.0
Ebuild name:

net-wireless/uhd-4.11.0.0

Description

Universal Software Radio Peripheral (USRP) Hardware Driver

Added to portage

2026-11-09

urjtag - 2021.03-r1
Ebuild name:

dev-embedded/urjtag-2021.03-r1

Description

Tool for communicating over JTAG with flash chips, CPUs, and many mo

Added to portage

2026-11-09

virtualbox - 7.2.18-r1
Ebuild name:

app-emulation/virtualbox-7.2.18-r1

Description

Family of powerful x86 virtualization products for enterprise an

Added to portage

2026-11-09

virtualbox - 7.2.22-r1
Ebuild name:

app-emulation/virtualbox-7.2.22-r1

Description

Family of powerful x86 virtualization products for enterprise an

Added to portage

2026-11-09

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