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:

88737

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-09-28
aiohttp - 3.14.3-r1
Ebuild name:

dev-python/aiohttp-3.14.3-r1

Description

HTTP client/server for asyncio

Added to portage

2026-09-28

cypari2 - 2.2.4-r1
Ebuild name:

dev-python/cypari2-2.2.4-r1

Description

Cython interface to PARI

Added to portage

2026-09-28

gcc - 14.4.1_p20260924
Ebuild name:

sys-devel/gcc-14.4.1_p20260924

Description

The GNU Compiler Collection

Added to portage

2026-09-28

gcc - 15.3.1_p20260925
Ebuild name:

sys-devel/gcc-15.3.1_p20260925

Description

The GNU Compiler Collection

Added to portage

2026-09-28

gcc - 16.2.1_p20260926
Ebuild name:

sys-devel/gcc-16.2.1_p20260926

Description

The GNU Compiler Collection

Added to portage

2026-09-28

ghostscript-gpl - 10.08.0
Ebuild name:

app-text/ghostscript-gpl-10.08.0

Description

Interpreter for the PostScript language and PDF

Added to portage

2026-09-28

gramps - 6.0.8-r1
Ebuild name:

app-misc/gramps-6.0.8-r1

Description

Community genealogy program aiming to be both intuitive and feature-comple

Added to portage

2026-09-28

imagemagick - 7.1.2.32
Ebuild name:

media-gfx/imagemagick-7.1.2.32

Description

A collection of tools and libraries for many image formats

Added to portage

2026-09-28

intel-graphics-compiler - 2.41.9-r1
Ebuild name:

dev-util/intel-graphics-compiler-2.41.9-r1

Description

LLVM-based OpenCL compiler for OpenCL targetting Intel G

Added to portage

2026-09-28

netcdf-cxx - 4.3.1-r2
Ebuild name:

sci-libs/netcdf-cxx-4.3.1-r2

Description

C++ library for netCDF

Added to portage

2026-09-28

pari - 2.17.4
Ebuild name:

sci-mathematics/pari-2.17.4

Description

Computer-aided number theory C library and tools

Added to portage

2026-09-28

2026-09-27
atuin - 18.23.0
Ebuild name:

app-shells/atuin-18.23.0

Description

Shell history manager supporting encrypted synchronisation

Added to portage

2026-09-27

avrdude - 8.3
Ebuild name:

dev-embedded/avrdude-8.3

Description

AVR Downloader/UploaDEr

Added to portage

2026-09-27

baikal - 0.12.1
Ebuild name:

www-apps/baikal-0.12.1

Description

Lightweight CalDAV+CardDAV server

Added to portage

2026-09-27

cattrs - 26.2.1
Ebuild name:

dev-python/cattrs-26.2.1

Description

Composable complex class support for attrs and dataclasses

Added to portage

2026-09-27

clinfo - 3.1.26.09.26
Ebuild name:

dev-util/clinfo-3.1.26.09.26

Description

A tool to display info about the system's OpenCL capabilities

Added to portage

2026-09-27

cpptest - 2.0.1
Ebuild name:

dev-util/cpptest-2.0.1

Description

Simple but powerful unit testing framework for C++

Added to portage

2026-09-27

deprecated - 3.0.0
Ebuild name:

dev-python/deprecated-3.0.0

Description

Python @deprecated decorator to deprecate old API

Added to portage

2026-09-27

drupal - 10.6.18
Ebuild name:

www-apps/drupal-10.6.18

Description

PHP-based open-source platform and content management system

Added to portage

2026-09-27

drupal - 11.3.17
Ebuild name:

www-apps/drupal-11.3.17

Description

PHP-based open-source platform and content management system

Added to portage

2026-09-27

drupal - 11.4.8
Ebuild name:

www-apps/drupal-11.4.8

Description

PHP-based open-source platform and content management system

Added to portage

2026-09-27

filelock - 4.0.4
Ebuild name:

dev-python/filelock-4.0.4

Description

A platform independent file lock for Python

Added to portage

2026-09-27

gexiv2 - 0.14.7-r1
Ebuild name:

media-libs/gexiv2-0.14.7-r1

Description

GObject-based wrapper around the Exiv2 library

Added to portage

2026-09-27

gtk+ - 2.24.33-r4
Ebuild name:

x11-libs/gtk+-2.24.33-r4

Description

Gimp ToolKit +

Added to portage

2026-09-27

identify - 2.6.20
Ebuild name:

dev-python/identify-2.6.20

Description

File identification library for Python

Added to portage

2026-09-27

inotify-tools - 4.26.262
Ebuild name:

sys-fs/inotify-tools-4.26.262

Description

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

Added to portage

2026-09-27

intel-microcode - 20260925_p20260925
Ebuild name:

sys-firmware/intel-microcode-20260925_p20260925

Description

Intel IA32/IA64 microcode update data

Added to portage

2026-09-27

knowit - 0.7.1
Ebuild name:

dev-python/knowit-0.7.1

Description

Know better your media files

Added to portage

2026-09-27

libvmaf - 3.2.1
Ebuild name:

media-libs/libvmaf-3.2.1

Description

C libary for Netflix's Perceptual video quality assessment

Added to portage

2026-09-27

meson-python - 0.22.0
Ebuild name:

dev-python/meson-python-0.22.0

Description

Meson PEP 517 Python build backend

Added to portage

2026-09-27

multidict - 7.0.0
Ebuild name:

dev-python/multidict-7.0.0

Description

multidict implementation

Added to portage

2026-09-27

netcdf - 4.10.1-r1
Ebuild name:

sci-libs/netcdf-4.10.1-r1

Description

Scientific library and interface for array oriented data access

Added to portage

2026-09-27

netcdf - 4.9.3-r3
Ebuild name:

sci-libs/netcdf-4.9.3-r3

Description

Scientific library and interface for array oriented data access

Added to portage

2026-09-27

networkmanager - 1.58.1-r2
Ebuild name:

net-misc/networkmanager-1.58.1-r2

Description

A set of co-operative tools that make networking simple and strai

Added to portage

2026-09-27

nodeenv - 1.11.0
Ebuild name:

dev-python/nodeenv-1.11.0

Description

Node.js virtual environment builder

Added to portage

2026-09-27

owasp-java-encoder - 1.4.1
Ebuild name:

dev-java/owasp-java-encoder-1.4.1

Description

OWASP Java Encoder

Added to portage

2026-09-27

papers - 50.3
Ebuild name:

app-text/papers-50.3

Description

A document viewer for the GNOME desktop

Added to portage

2026-09-27

pikepdf - 10.14.0
Ebuild name:

dev-python/pikepdf-10.14.0

Description

Python library to work with pdf files based on qpdf

Added to portage

2026-09-27

pkgcheck - 0.10.45
Ebuild name:

dev-util/pkgcheck-0.10.45

Description

pkgcore-based QA utility for ebuild repos

Added to portage

2026-09-27

pkgcore - 0.12.44
Ebuild name:

sys-apps/pkgcore-0.12.44

Description

a framework for package management

Added to portage

2026-09-27

platformdirs - 4.12.0
Ebuild name:

dev-python/platformdirs-4.12.0

Description

A small Python module for determining appropriate platform-specific

Added to portage

2026-09-27

postfix - 3.12_pre20260925
Ebuild name:

mail-mta/postfix-3.12_pre20260925

Description

A fast and secure drop-in replacement for sendmail

Added to portage

2026-09-27

qpdf - 12.4.2
Ebuild name:

app-text/qpdf-12.4.2

Description

Command-line tool for structural, content-preserving transformation of PDF fil

Added to portage

2026-09-27

rope - 1.15.0
Ebuild name:

dev-python/rope-1.15.0

Description

Python refactoring library

Added to portage

2026-09-27

shader-slang - 2026.18.3
Ebuild name:

dev-util/shader-slang-2026.18.3

Description

Making it easier to work with shaders

Added to portage

2026-09-27

umockdev - 0.19.9
Ebuild name:

dev-util/umockdev-0.19.9

Description

Mock hardware devices for creating unit tests

Added to portage

2026-09-27

vips - 8.18.7
Ebuild name:

media-libs/vips-8.18.7

Description

VIPS Image Processing Library

Added to portage

2026-09-27

virtualenv - 21.13.0
Ebuild name:

dev-python/virtualenv-21.13.0

Description

Virtual Python Environment builder

Added to portage

2026-09-27

zsnes - 2.3.3
Ebuild name:

games-emulation/zsnes-2.3.3

Description

Fork of the classic Super Nintendo emulator

Added to portage

2026-09-27

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