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:

89567

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-10-26
aria2 - 1.37.0-r1
Ebuild name:

net-misc/aria2-1.37.0-r1

Description

A download utility with segmented downloading with BitTorrent support

Added to portage

2026-10-26

compose-tables - 1.8.14
Ebuild name:

x11-misc/compose-tables-1.8.14

Description

X.Org Compose Key tables from libX11

Added to portage

2026-10-26

curl - 8.23.0-r1
Ebuild name:

net-misc/curl-8.23.0-r1

Description

A Client that groks URLs

Added to portage

2026-10-26

gawk - 5.4.1c
Ebuild name:

sys-apps/gawk-5.4.1c

Description

GNU awk pattern-matching language

Added to portage

2026-10-26

gcc - 14.4.1_p20261022
Ebuild name:

sys-devel/gcc-14.4.1_p20261022

Description

The GNU Compiler Collection

Added to portage

2026-10-26

gcc - 15.3.1_p20261023
Ebuild name:

sys-devel/gcc-15.3.1_p20261023

Description

The GNU Compiler Collection

Added to portage

2026-10-26

gcc - 16.2.1_p20261024
Ebuild name:

sys-devel/gcc-16.2.1_p20261024

Description

The GNU Compiler Collection

Added to portage

2026-10-26

gcc - 17.0.0_p20261025
Ebuild name:

sys-devel/gcc-17.0.0_p20261025

Description

The GNU Compiler Collection

Added to portage

2026-10-26

johntheripper - 1.8.0-r2
Ebuild name:

app-crypt/johntheripper-1.8.0-r2

Description

fast password cracker

Added to portage

2026-10-26

johntheripper - 1.9.0
Ebuild name:

app-crypt/johntheripper-1.9.0

Description

fast password cracker

Added to portage

2026-10-26

johntheripper-jumbo - 1.9.0_p20240102
Ebuild name:

app-crypt/johntheripper-jumbo-1.9.0_p20240102

Description

Fast password cracker, community enhanced version

Added to portage

2026-10-26

johntheripper-jumbo - 1.9.0_p20250216-r1
Ebuild name:

app-crypt/johntheripper-jumbo-1.9.0_p20250216-r1

Description

Fast password cracker, community enhanced version

Added to portage

2026-10-26

johntheripper-jumbo - 1.9.0_p20250703
Ebuild name:

app-crypt/johntheripper-jumbo-1.9.0_p20250703

Description

Fast password cracker, community enhanced version

Added to portage

2026-10-26

johntheripper-jumbo - 9999
Ebuild name:

app-crypt/johntheripper-jumbo-9999

Description

Fast password cracker, community enhanced version

Added to portage

2026-10-26

kali-archive-keyring - 2020.2
Ebuild name:

app-crypt/kali-archive-keyring-2020.2

Description

GnuPG archive keys of the Kali archive

Added to portage

2026-10-26

kbfs - 6.0.2
Ebuild name:

app-crypt/kbfs-6.0.2

Description

Keybase Filesystem (KBFS)

Added to portage

2026-10-26

kbfs - 6.2.4
Ebuild name:

app-crypt/kbfs-6.2.4

Description

Keybase Filesystem (KBFS)

Added to portage

2026-10-26

language-c - 0.10.2
Ebuild name:

dev-haskell/language-c-0.10.2

Description

Analysis and generation of C code

Added to portage

2026-10-26

libplacebo - 7.387.0
Ebuild name:

media-libs/libplacebo-7.387.0

Description

Reusable library for GPU-accelerated image processing primitives

Added to portage

2026-10-26

openssh-legacy - 9.9_p2-r1
Ebuild name:

net-misc/openssh-legacy-9.9_p2-r1

Description

Old versions of OpenSSH installed separately for legacy machines

Added to portage

2026-10-26

pgbouncer - 1.26.1
Ebuild name:

dev-db/pgbouncer-1.26.1

Description

Lightweight connection pooler for PostgreSQL

Added to portage

2026-10-26

systemd - 262.1
Ebuild name:

sys-apps/systemd-262.1

Description

System and service manager for Linux

Added to portage

2026-10-26

tls - 2.0.1
Ebuild name:

dev-tcltk/tls-2.0.1

Description

TLS OpenSSL extension to Tcl

Added to portage

2026-10-26

2026-10-25
amf-headers - 1.5.2
Ebuild name:

media-libs/amf-headers-1.5.2

Description

The Advanced Media Framework (AMF) SDK

Added to portage

2026-10-25

apprise - 2.1.0
Ebuild name:

dev-python/apprise-2.1.0

Description

Push Notifications that work with just about every platform

Added to portage

2026-10-25

berkeleydb - 18.1.17
Ebuild name:

dev-python/berkeleydb-18.1.17

Description

Python bindings for Oracle Berkeley DB

Added to portage

2026-10-25

capnproto - 1.5.0
Ebuild name:

dev-libs/capnproto-1.5.0

Description

RPC/Serialization system with capabilities support

Added to portage

2026-10-25

cmd2 - 4.3.1
Ebuild name:

dev-python/cmd2-4.3.1

Description

Extra features for standard library's cmd module

Added to portage

2026-10-25

discord - 1.0.166
Ebuild name:

net-im/discord-1.0.166

Description

All-in-one voice and text chat for gamers

Added to portage

2026-10-25

efitools - 1.9.2_p1
Ebuild name:

app-crypt/efitools-1.9.2_p1

Description

Tools for manipulating UEFI secure boot platforms

Added to portage

2026-10-25

electrum - 4.8.3
Ebuild name:

net-misc/electrum-4.8.3

Description

User friendly Bitcoin client

Added to portage

2026-10-25

gallery-dl - 1.32.17-r1
Ebuild name:

net-misc/gallery-dl-1.32.17-r1

Description

Download image galleries and collections from several image hosting

Added to portage

2026-10-25

gallery-dl - 1.32.18
Ebuild name:

net-misc/gallery-dl-1.32.18

Description

Download image galleries and collections from several image hosting sit

Added to portage

2026-10-25

git - 2.56.0-r1
Ebuild name:

dev-vcs/git-2.56.0-r1

Description

Stupid content tracker distributed VCS designed for speed and efficiency

Added to portage

2026-10-25

gnupg - 2.5.24-r2
Ebuild name:

app-crypt/gnupg-2.5.24-r2

Description

The GNU Privacy Guard, a GPL OpenPGP implementation

Added to portage

2026-10-25

icu4j - 79.1
Ebuild name:

dev-java/icu4j-79.1

Description

A set of Java libraries providing Unicode and Globalization support

Added to portage

2026-10-25

isync - 1.5.1-r1
Ebuild name:

net-mail/isync-1.5.1-r1

Description

MailDir mailbox synchronizer

Added to portage

2026-10-25

jsonpatch - 1.37
Ebuild name:

dev-python/jsonpatch-1.37

Description

Apply JSON-Patches like http

Added to portage

2026-10-25

jsonpointer - 3.5
Ebuild name:

dev-python/jsonpointer-3.5

Description

Identify specific nodes in a JSON document (according to draft 08)

Added to portage

2026-10-25

log4j-core - 2.26.0-r1
Ebuild name:

dev-java/log4j-core-2.26.0-r1

Description

The Apache Log4j Implementation

Added to portage

2026-10-25

lucene - 2.4.1-r6
Ebuild name:

dev-java/lucene-2.4.1-r6

Description

High-performance, full-featured text search engine written entirely in Jav

Added to portage

2026-10-25

multidict - 7.2.1
Ebuild name:

dev-python/multidict-7.2.1

Description

multidict implementation

Added to portage

2026-10-25

mysql-connector-c - 26.10.0
Ebuild name:

dev-db/mysql-connector-c-26.10.0

Description

C client library for MariaDB/MySQL

Added to portage

2026-10-25

mysql-connector-c - 8.0.46
Ebuild name:

dev-db/mysql-connector-c-8.0.46

Description

C client library for MariaDB/MySQL

Added to portage

2026-10-25

openssh - 0-r2
Ebuild name:

virtual/openssh-0-r2

Description

Virtual for net-misc/openssh and variants

Added to portage

2026-10-25

pam_p11 - 0.6.1
Ebuild name:

sys-auth/pam_p11-0.6.1

Description

PAM module for authenticating against PKCS11 tokens

Added to portage

2026-10-25

pcsc-lite - 2.5.3
Ebuild name:

sys-apps/pcsc-lite-2.5.3

Description

PC/SC Architecture smartcard middleware library

Added to portage

2026-10-25

pcsc-tools - 1.7.5
Ebuild name:

sys-apps/pcsc-tools-1.7.5

Description

PC/SC Architecture smartcard tools

Added to portage

2026-10-25

pkcs11-provider - 1.3.0
Ebuild name:

dev-libs/pkcs11-provider-1.3.0

Description

OpenSSL 3+ provider to access hardware or software tokens via PKCS11

Added to portage

2026-10-25

pkgcheck - 0.10.49
Ebuild name:

dev-util/pkgcheck-0.10.49

Description

pkgcore-based QA utility for ebuild repos

Added to portage

2026-10-25

pkgcore - 0.12.48
Ebuild name:

sys-apps/pkgcore-0.12.48

Description

a framework for package management

Added to portage

2026-10-25

pkgdev - 0.2.19
Ebuild name:

dev-util/pkgdev-0.2.19

Description

Collection of tools for Gentoo development

Added to portage

2026-10-25

publicsuffix-db - 20260907
Ebuild name:

net-misc/publicsuffix-db-20260907

Description

The Public Suffix List

Added to portage

2026-10-25

pycryptodome - 4.2.0
Ebuild name:

dev-python/pycryptodome-4.2.0

Description

A self-contained cryptographic library for Python

Added to portage

2026-10-25

qbittorrent - 5.3.0
Ebuild name:

net-p2p/qbittorrent-5.3.0

Description

BitTorrent client in C++ and Qt

Added to portage

2026-10-25

simdutf - 9.3.2
Ebuild name:

dev-cpp/simdutf-9.3.2

Description

Unicode validation and transcoding at billions of characters per second

Added to portage

2026-10-25

softhsm - 2.7.0
Ebuild name:

dev-libs/softhsm-2.7.0

Description

A software PKCS11 implementation

Added to portage

2026-10-25

starlette - 1.10.0
Ebuild name:

dev-python/starlette-1.10.0

Description

The little ASGI framework that shines

Added to portage

2026-10-25

sun-jai-bin - 1.1.3-r4
Ebuild name:

dev-java/sun-jai-bin-1.1.3-r4

Description

JAI is a class library for managing images

Added to portage

2026-10-25

sunshine - 2026.914.233613
Ebuild name:

net-misc/sunshine-2026.914.233613

Description

Self-hosted game stream host for Moonlight

Added to portage

2026-10-25

wcwidth - 0.9.4
Ebuild name:

dev-python/wcwidth-0.9.4

Description

Measures number of Terminal column cells of wide-character codes

Added to portage

2026-10-25

wtforms - 3.3.1
Ebuild name:

dev-python/wtforms-3.3.1

Description

Flexible forms validation and rendering library for python web development

Added to portage

2026-10-25

zoitechat - 2.19.1
Ebuild name:

net-irc/zoitechat-2.19.1

Description

GTK+ IRC client that's a fork of HexChat

Added to portage

2026-10-25

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