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:

82789

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-01-12
binary-orphans - 1.0.5
Ebuild name:

dev-haskell/binary-orphans-1.0.5

Description

Compatibility package for binary; provides instances

Added to portage

2026-01-12

bitvec - 1.1.5.0
Ebuild name:

dev-haskell/bitvec-1.1.5.0

Description

Space-efficient bit vectors

Added to portage

2026-01-12

calligraplan - 4.0.1
Ebuild name:

app-office/calligraplan-4.0.1

Description

Project management application

Added to portage

2026-01-12

dulwich - 0.25.2
Ebuild name:

dev-python/dulwich-0.25.2

Description

Pure-Python implementation of the Git file formats and protocols

Added to portage

2026-01-12

hishel - 1.1.8
Ebuild name:

dev-python/hishel-1.1.8

Description

An elegant HTTP Cache implementation for HTTPX and HTTP Core

Added to portage

2026-01-12

inkscape - 1.4.3
Ebuild name:

media-gfx/inkscape-1.4.3

Description

SVG based generic vector-drawing program

Added to portage

2026-01-12

kdevelop - 25.12.1-r1
Ebuild name:

dev-util/kdevelop-25.12.1-r1

Description

Integrated Development Environment, supporting KF6/Qt, C/C++ and much

Added to portage

2026-01-12

onetuple - 0.4.2.1
Ebuild name:

dev-haskell/onetuple-0.4.2.1

Description

Singleton Tuple

Added to portage

2026-01-12

openpgp-keys-gentoo-developers - 20260105
Ebuild name:

sec-keys/openpgp-keys-gentoo-developers-20260105

Description

Gentoo Authority Keys (GLEP 79)

Added to portage

2026-01-12

pcsx2 - 2.6.2
Ebuild name:

games-emulation/pcsx2-2.6.2

Description

PlayStation 2 emulator

Added to portage

2026-01-12

regex-base - 0.94.0.3
Ebuild name:

dev-haskell/regex-base-0.94.0.3

Description

Common

Added to portage

2026-01-12

regex-posix - 0.96.0.2
Ebuild name:

dev-haskell/regex-posix-0.96.0.2

Description

POSIX Backend for

Added to portage

2026-01-12

ruby-cairo-gobject - 4.3.4
Ebuild name:

dev-ruby/ruby-cairo-gobject-4.3.4

Description

Ruby cairo-gobject bindings

Added to portage

2026-01-12

ruby-gio2 - 4.3.4-r1
Ebuild name:

dev-ruby/ruby-gio2-4.3.4-r1

Description

Ruby binding of gio-2

Added to portage

2026-01-12

ruby-glib2 - 4.3.4-r1
Ebuild name:

dev-ruby/ruby-glib2-4.3.4-r1

Description

Ruby Glib2 bindings

Added to portage

2026-01-12

ruby-gobject-introspection - 4.3.4-r1
Ebuild name:

dev-ruby/ruby-gobject-introspection-4.3.4-r1

Description

Ruby GObjectIntrospection bindings

Added to portage

2026-01-12

ruby-poppler - 4.3.4
Ebuild name:

dev-ruby/ruby-poppler-4.3.4

Description

Ruby poppler-glib bindings

Added to portage

2026-01-12

systemd - 259
Ebuild name:

sys-apps/systemd-259

Description

System and service manager for Linux

Added to portage

2026-01-12

whenever - 0.9.5
Ebuild name:

dev-python/whenever-0.9.5

Description

Modern datetime library for Python

Added to portage

2026-01-12

2026-01-11
aiodns - 4.0.0
Ebuild name:

dev-python/aiodns-4.0.0

Description

Simple DNS resolver for asyncio

Added to portage

2026-01-11

alsa-firmware - 1.2.4-r2
Ebuild name:

sys-firmware/alsa-firmware-1.2.4-r2

Description

Advanced Linux Sound Architecture firmware

Added to portage

2026-01-11

alsa-tools - 1.2.15-r1
Ebuild name:

media-sound/alsa-tools-1.2.15-r1

Description

Advanced Linux Sound Architecture tools

Added to portage

2026-01-11

ansi-terminal - 1.1.5
Ebuild name:

dev-haskell/ansi-terminal-1.1.5

Description

Simple ANSI terminal support

Added to portage

2026-01-11

ansi-terminal-types - 1.1.3
Ebuild name:

dev-haskell/ansi-terminal-types-1.1.3

Description

Types and functions used to represent SGR aspects

Added to portage

2026-01-11

assoc - 1.1.1
Ebuild name:

dev-haskell/assoc-1.1.1

Description

swap and assoc Symmetric and Semigroupy Bifunctors

Added to portage

2026-01-11

bcachefs-kmod - 1.34.0
Ebuild name:

sys-fs/bcachefs-kmod-1.34.0

Description

Linux bcachefs kernel module for sys-fs/bcachefs-tools

Added to portage

2026-01-11

bcachefs-kmod - 9999
Ebuild name:

sys-fs/bcachefs-kmod-9999

Description

Linux bcachefs kernel module for sys-fs/bcachefs-tools

Added to portage

2026-01-11

bifunctors - 5.6.3
Ebuild name:

dev-haskell/bifunctors-5.6.3

Description

Haskell 98 bifunctors, bifoldables and bitraversables

Added to portage

2026-01-11

clock - 0.8.4
Ebuild name:

dev-haskell/clock-0.8.4

Description

High-resolution clock functions monotonic, realtime, cputime

Added to portage

2026-01-11

cmake - 4.2.1-r1
Ebuild name:

dev-build/cmake-4.2.1-r1

Description

Cross platform Make

Added to portage

2026-01-11

comonad - 5.0.10
Ebuild name:

dev-haskell/comonad-5.0.10

Description

Provides comonads, the categorical dual of monads

Added to portage

2026-01-11

cstruct - 6.2
Ebuild name:

dev-python/cstruct-6.2

Description

C-style structs for Python

Added to portage

2026-01-11

cyme - 2.2.10
Ebuild name:

sys-apps/cyme-2.2.10

Description

List system USB buses and devices; a modern cross-platform `lsusb`

Added to portage

2026-01-11

data-array-byte - 0.1.0.2
Ebuild name:

dev-haskell/data-array-byte-0.1.0.2

Description

Compatibility layer for Data.Array.Byte

Added to portage

2026-01-11

data-fix - 0.3.4
Ebuild name:

dev-haskell/data-fix-0.3.4

Description

Fixpoint data types

Added to portage

2026-01-11

flexmock - 0.13.0
Ebuild name:

dev-python/flexmock-0.13.0

Description

Testing library to create mocks, stubs and fakes

Added to portage

2026-01-11

foldable1-classes-compat - 0.1.3
Ebuild name:

dev-haskell/foldable1-classes-compat-0.1.3

Description

Compatibility package for the Foldable1 and Bifoldable1

Added to portage

2026-01-11

generically - 0.1.1-r2
Ebuild name:

dev-haskell/generically-0.1.1-r2

Description

Generically newtype to use with DerivingVia

Added to portage

2026-01-11

git - 4.1.2
Ebuild name:

dev-ruby/git-4.1.2

Description

Library for using Git in Ruby

Added to portage

2026-01-11

hashable - 1.4.7.0
Ebuild name:

dev-haskell/hashable-1.4.7.0

Description

A class for types that can be converted to a hash value

Added to portage

2026-01-11

indexed-traversable - 0.1.4
Ebuild name:

dev-haskell/indexed-traversable-0.1.4

Description

FunctorWithIndex, FoldableWithIndex, TraversableWithIndex

Added to portage

2026-01-11

indexed-traversable-instances - 0.1.2
Ebuild name:

dev-haskell/indexed-traversable-instances-0.1.2

Description

More instances of FunctorWithIndex, FoldableWithInd

Added to portage

2026-01-11

inspection-testing - 0.6
Ebuild name:

dev-haskell/inspection-testing-0.6

Description

GHC plugin to do inspection testing

Added to portage

2026-01-11

libmateweather - 1.28.1-r2
Ebuild name:

dev-libs/libmateweather-1.28.1-r2

Description

MATE library to access weather information from online services

Added to portage

2026-01-11

linux-firmware - 20251125_p20251229
Ebuild name:

sys-kernel/linux-firmware-20251125_p20251229

Description

Linux firmware files

Added to portage

2026-01-11

mtl - 2.2.2-r2
Ebuild name:

dev-haskell/mtl-2.2.2-r2

Description

Monad classes, using functional dependencies

Added to portage

2026-01-11

mutter - 48.6-r1
Ebuild name:

x11-wm/mutter-48.6-r1

Description

GNOME compositing window manager based on Clutter

Added to portage

2026-01-11

onnx - 1.20.1
Ebuild name:

sci-ml/onnx-1.20.1

Description

Open Neural Network Exchange (ONNX)

Added to portage

2026-01-11

os-string - 2.0.7
Ebuild name:

dev-haskell/os-string-2.0.7

Description

Library for manipulating Operating system strings

Added to portage

2026-01-11

os-string - 2.0.8
Ebuild name:

dev-haskell/os-string-2.0.8

Description

Library for manipulating Operating system strings

Added to portage

2026-01-11

pcre-light - 0.4.1.3
Ebuild name:

dev-haskell/pcre-light-0.4.1.3

Description

Portable regex library for Perl 5 compatible regular expressions

Added to portage

2026-01-11

postfix - 3.12_pre20260110
Ebuild name:

mail-mta/postfix-3.12_pre20260110

Description

A fast and secure drop-in replacement for sendmail

Added to portage

2026-01-11

qpdf - 12.3.0
Ebuild name:

app-text/qpdf-12.3.0

Description

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

Added to portage

2026-01-11

quickcheck - 2.14.3-r1
Ebuild name:

dev-haskell/quickcheck-2.14.3-r1

Description

Automatic testing of Haskell programs

Added to portage

2026-01-11

quickcheck-classes-base - 0.6.2.0-r1
Ebuild name:

dev-haskell/quickcheck-classes-base-0.6.2.0-r1

Description

QuickCheck common typeclasses from 'base'

Added to portage

2026-01-11

random - 1.2.1.3
Ebuild name:

dev-haskell/random-1.2.1.3

Description

Pseudo-random number generation

Added to portage

2026-01-11

rb_sys - 0.9.124
Ebuild name:

dev-ruby/rb_sys-0.9.124

Description

Easily build Ruby native extensions in Rust

Added to portage

2026-01-11

scipy - 1.17.0
Ebuild name:

dev-python/scipy-1.17.0

Description

Scientific algorithms library for Python

Added to portage

2026-01-11

starlette - 0.51.0
Ebuild name:

dev-python/starlette-0.51.0

Description

The little ASGI framework that shines

Added to portage

2026-01-11

statevar - 1.2.2-r1
Ebuild name:

dev-haskell/statevar-1.2.2-r1

Description

State variables

Added to portage

2026-01-11

syd - 3.48.4
Ebuild name:

sys-apps/syd-3.48.4

Description

seccomp and landlock based application sandbox with support for namespaces

Added to portage

2026-01-11

tagged - 0.8.10
Ebuild name:

dev-haskell/tagged-0.8.10

Description

Haskell 98 phantom types to avoid unsafely passing dummy arguments

Added to portage

2026-01-11

tasty-inspection-testing - 0.2.1-r1
Ebuild name:

dev-haskell/tasty-inspection-testing-0.2.1-r1

Description

Inspection testing support for tasty

Added to portage

2026-01-11

tavern - 3.1.0
Ebuild name:

dev-python/tavern-3.1.0

Description

A tool, library, and Pytest plugin for testing RESTful APIs

Added to portage

2026-01-11

th-abstraction - 0.7.2.0
Ebuild name:

dev-haskell/th-abstraction-0.7.2.0

Description

Nicer interface for reified information about data types

Added to portage

2026-01-11

tomli - 2.4.0
Ebuild name:

dev-python/tomli-2.4.0

Description

A lil' TOML parser

Added to portage

2026-01-11

vector - 0.13.2.0
Ebuild name:

dev-haskell/vector-0.13.2.0

Description

Efficient Arrays

Added to portage

2026-01-11

vector-stream - 0.1.0.1
Ebuild name:

dev-haskell/vector-stream-0.1.0.1

Description

Efficient Streams

Added to portage

2026-01-11

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