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:

82647

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
2025-12-30
fakefs - 3.2.0
Ebuild name:

dev-ruby/fakefs-3.2.0

Description

A fake filesystem. Use it in your tests

Added to portage

2025-12-30

fiddle - 1.1.8
Ebuild name:

dev-ruby/fiddle-1.1.8

Description

A libffi wrapper for Ruby

Added to portage

2025-12-30

git - 4.0.7
Ebuild name:

dev-ruby/git-4.0.7

Description

Library for using Git in Ruby

Added to portage

2025-12-30

httparty - 0.24.0
Ebuild name:

dev-ruby/httparty-0.24.0

Description

Makes http fun Also, makes consuming restful web services dead easy

Added to portage

2025-12-30

krita - 6.0.0_alpha_pre20251229
Ebuild name:

media-gfx/krita-6.0.0_alpha_pre20251229

Description

Free digital painting application. Digital Painting, Creati

Added to portage

2025-12-30

libcamera - 0.6.0
Ebuild name:

media-libs/libcamera-0.6.0

Description

Complex camera support library

Added to portage

2025-12-30

portage-utils - 0.98
Ebuild name:

app-portage/portage-utils-0.98

Description

Small and fast Portage helper tools written in C

Added to portage

2025-12-30

pstore - 0.2.0
Ebuild name:

dev-ruby/pstore-0.2.0

Description

Transactional File Storage for Ruby Objects

Added to portage

2025-12-30

qcheck - 0.27
Ebuild name:

dev-ml/qcheck-0.27

Description

QuickCheck inspired property-based testing for OCaml

Added to portage

2025-12-30

readline - 0.0.4
Ebuild name:

dev-ruby/readline-0.0.4

Description

Class to build custom data structures, similar to a Hash

Added to portage

2025-12-30

2025-12-29
array-api-compat - 1.13.0
Ebuild name:

dev-python/array-api-compat-1.13.0

Description

Array API standard compatibility wrapper over NumPy and others

Added to portage

2025-12-29

coverage - 7.13.1
Ebuild name:

dev-python/coverage-7.13.1

Description

Code coverage measurement for Python

Added to portage

2025-12-29

darktable - 5.4.0
Ebuild name:

media-gfx/darktable-5.4.0

Description

A virtual lighttable and darkroom for photographers

Added to portage

2025-12-29

elementpath - 5.1.0
Ebuild name:

dev-python/elementpath-5.1.0

Description

XPath 1.0/2.0 parsers and selectors for ElementTree and lxml

Added to portage

2025-12-29

gcc - 15.2.1_p20251227
Ebuild name:

sys-devel/gcc-15.2.1_p20251227

Description

The GNU Compiler Collection

Added to portage

2025-12-29

gcc - 16.0.0_p20251228
Ebuild name:

sys-devel/gcc-16.0.0_p20251228

Description

The GNU Compiler Collection

Added to portage

2025-12-29

git-sources - 6.19_rc3
Ebuild name:

sys-kernel/git-sources-6.19_rc3

Description

The very latest -git version of the Linux kernel

Added to portage

2025-12-29

harfbuzz - 12.3.0
Ebuild name:

media-libs/harfbuzz-12.3.0

Description

An OpenType text shaping engine

Added to portage

2025-12-29

hugin - 2025.0.1
Ebuild name:

media-gfx/hugin-2025.0.1

Description

GUI for the creation & processing of panoramic images

Added to portage

2025-12-29

kshutdown - 6.2
Ebuild name:

kde-misc/kshutdown-6.2

Description

Shutdown manager for desktop environments like KDE Plasma

Added to portage

2025-12-29

lcov - 2.4
Ebuild name:

dev-util/lcov-2.4

Description

A graphical front-end for GCC's coverage testing tool gcov

Added to portage

2025-12-29

libxfce4windowing - 4.20.5
Ebuild name:

xfce-base/libxfce4windowing-4.20.5

Description

Unified widget and session management libs for Xfce

Added to portage

2025-12-29

mediafile - 0.14.0
Ebuild name:

dev-python/mediafile-0.14.0

Description

Read and write audio files' tags in Python

Added to portage

2025-12-29

messagelib - 25.08.3-r2
Ebuild name:

kde-apps/messagelib-25.08.3-r2

Description

Libraries for messaging functions

Added to portage

2025-12-29

moto - 5.1.19
Ebuild name:

dev-python/moto-5.1.19

Description

Mock library for boto

Added to portage

2025-12-29

netavark - 1.17.1
Ebuild name:

app-containers/netavark-1.17.1

Description

A container network stack

Added to portage

2025-12-29

newsboat - 2.42
Ebuild name:

net-news/newsboat-2.42

Description

An RSS/Atom feed reader for text terminals

Added to portage

2025-12-29

openresolv - 3.17.4
Ebuild name:

net-dns/openresolv-3.17.4

Description

A framework for managing DNS information

Added to portage

2025-12-29

plette - 2.1.0-r1
Ebuild name:

dev-python/plette-2.1.0-r1

Description

Structured Pipfile and Pipfile.lock models

Added to portage

2025-12-29

postfix - 3.11.0_rc2
Ebuild name:

mail-mta/postfix-3.11.0_rc2

Description

A fast and secure drop-in replacement for sendmail

Added to portage

2025-12-29

postfix - 3.12_pre20251226
Ebuild name:

mail-mta/postfix-3.12_pre20251226

Description

A fast and secure drop-in replacement for sendmail

Added to portage

2025-12-29

pwsh - 7.5.4-r2
Ebuild name:

app-shells/pwsh-7.5.4-r2

Description

Cross-platform automation and configuration tool

Added to portage

2025-12-29

pycargoebuild - 0.15.1
Ebuild name:

app-portage/pycargoebuild-0.15.1

Description

A generator for Rust/Cargo ebuilds written in Python

Added to portage

2025-12-29

qmidiarp - 0.7.2
Ebuild name:

media-sound/qmidiarp-0.7.2

Description

Arpeggiator, sequencer and MIDI LFO for ALSA

Added to portage

2025-12-29

sedlex - 3.7
Ebuild name:

dev-ml/sedlex-3.7

Description

Added to portage

2025-12-29

socket-burst-dampener - 1.3.3
Ebuild name:

net-misc/socket-burst-dampener-1.3.3

Description

A daemon that spawns one command per connection, and dampens c

Added to portage

2025-12-29

tldextract - 5.3.1
Ebuild name:

dev-python/tldextract-5.3.1

Description

Accurately separate the TLD from the registered domain and subdomains o

Added to portage

2025-12-29

tlfloat - 1.15.0_p20250711
Ebuild name:

dev-cpp/tlfloat-1.15.0_p20250711

Description

C++ template library for floating point operations

Added to portage

2025-12-29

tumbler - 4.21.1
Ebuild name:

xfce-base/tumbler-4.21.1

Description

A thumbnail service for Thunar

Added to portage

2025-12-29

types-psutil - 7.2.0.20251228
Ebuild name:

dev-python/types-psutil-7.2.0.20251228

Description

Typing stubs for psutil

Added to portage

2025-12-29

vulkan-loader - 1.4.335.0-r1
Ebuild name:

media-libs/vulkan-loader-1.4.335.0-r1

Description

Vulkan Installable Client Driver (ICD) Loader

Added to portage

2025-12-29

xfce4-panel - 4.20.6
Ebuild name:

xfce-base/xfce4-panel-4.20.6

Description

Panel for the Xfce desktop environment

Added to portage

2025-12-29

xfce4-power-manager - 4.21.1
Ebuild name:

xfce-base/xfce4-power-manager-4.21.1

Description

Power manager for the Xfce desktop environment

Added to portage

2025-12-29

xfce4-settings - 4.21.1
Ebuild name:

xfce-base/xfce4-settings-4.21.1

Description

Configuration system for the Xfce desktop environment

Added to portage

2025-12-29

xwaylandvideobridge - 0.4.0_p20250215-r1
Ebuild name:

gui-apps/xwaylandvideobridge-0.4.0_p20250215-r1

Description

Screenshare Wayland windows to XWayland apps

Added to portage

2025-12-29

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