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:

82835

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-16
aseprite - 1.3.16.1
Ebuild name:

dev-games/aseprite-1.3.16.1

Description

Animated sprite editor & pixel art tool

Added to portage

2026-01-16

babl - 0.1.120
Ebuild name:

media-libs/babl-0.1.120

Description

A dynamic, any to any, pixel format conversion library

Added to portage

2026-01-16

blake3 - 1.8.3
Ebuild name:

dev-libs/blake3-1.8.3

Description

a fast cryptographic hash function

Added to portage

2026-01-16

capstone - 6.0.0_alpha6
Ebuild name:

dev-libs/capstone-6.0.0_alpha6

Description

disassembly/disassembler framework + bindings

Added to portage

2026-01-16

gajim - 2.4.2
Ebuild name:

net-im/gajim-2.4.2

Description

GTK XMPP Client

Added to portage

2026-01-16

icecast - 2.5.0
Ebuild name:

net-misc/icecast-2.5.0

Description

Opensource alternative to shoutcast that supports mp3, ogg and aac streaming

Added to portage

2026-01-16

ktls-utils - 1.3.0
Ebuild name:

net-misc/ktls-utils-1.3.0

Description

Kernel TLS helper utilities

Added to portage

2026-01-16

libigloo - 0.9.5
Ebuild name:

dev-libs/libigloo-0.9.5

Description

Generic framework for C development - used by the Icecast project

Added to portage

2026-01-16

libnice - 0.1.23
Ebuild name:

net-libs/libnice-0.1.23

Description

Implementation of the Interactice Connectivity Establishment standard (ICE)

Added to portage

2026-01-16

libnvidia-container - 1.18.1
Ebuild name:

sys-libs/libnvidia-container-1.18.1

Description

NVIDIA container runtime library

Added to portage

2026-01-16

ltrace - 0.8.1
Ebuild name:

dev-debug/ltrace-0.8.1

Description

trace library calls made at runtime

Added to portage

2026-01-16

mysql-connector-c - 8.0.36-r1
Ebuild name:

dev-db/mysql-connector-c-8.0.36-r1

Description

C client library for MariaDB/MySQL

Added to portage

2026-01-16

mysql-connector-c - 8.0.41-r1
Ebuild name:

dev-db/mysql-connector-c-8.0.41-r1

Description

C client library for MariaDB/MySQL

Added to portage

2026-01-16

nvidia-container-toolkit - 1.18.1
Ebuild name:

app-containers/nvidia-container-toolkit-1.18.1

Description

NVIDIA container runtime toolkit

Added to portage

2026-01-16

pdns-recursor - 5.3.4
Ebuild name:

net-dns/pdns-recursor-5.3.4

Description

The PowerDNS Recursor

Added to portage

2026-01-16

sccache - 0.13.0
Ebuild name:

dev-util/sccache-0.13.0

Description

ccache/distcc like tool with support for rust and cloud storage

Added to portage

2026-01-16

sssd - 2.12.0
Ebuild name:

sys-auth/sssd-2.12.0

Description

System Security Services Daemon provides access to identity and authentication

Added to portage

2026-01-16

termsyn - 1.8.7-r1
Ebuild name:

media-fonts/termsyn-1.8.7-r1

Description

Monospaced font based on terminus and tamsyn

Added to portage

2026-01-16

trojan - 1.16.0-r4
Ebuild name:

net-proxy/trojan-1.16.0-r4

Description

An unidentifiable mechanism that helps you bypass GFW

Added to portage

2026-01-16

yara-x - 1.11.0
Ebuild name:

app-forensics/yara-x-1.11.0

Description

A malware identification and classification tool

Added to portage

2026-01-16

zen-sources - 6.18.4
Ebuild name:

sys-kernel/zen-sources-6.18.4

Description

The Zen Kernel Live Sources

Added to portage

2026-01-16

zen-sources - 6.18.5
Ebuild name:

sys-kernel/zen-sources-6.18.5

Description

The Zen Kernel Live Sources

Added to portage

2026-01-16

2026-01-15
alembic - 1.18.1
Ebuild name:

dev-python/alembic-1.18.1

Description

Database migrations tool, written by the author of SQLAlchemy

Added to portage

2026-01-15

atuin - 18.11.0
Ebuild name:

app-shells/atuin-18.11.0

Description

Shell history manager supporting encrypted synchronisation

Added to portage

2026-01-15

awscli - 1.44.18
Ebuild name:

app-admin/awscli-1.44.18

Description

Universal Command Line Environment for AWS

Added to portage

2026-01-15

boto3 - 1.42.28
Ebuild name:

dev-python/boto3-1.42.28

Description

The AWS SDK for Python

Added to portage

2026-01-15

botocore - 1.42.28
Ebuild name:

dev-python/botocore-1.42.28

Description

Low-level, data-driven core of boto 3

Added to portage

2026-01-15

chef-utils - 18.9.4
Ebuild name:

dev-ruby/chef-utils-18.9.4

Description

Basic utility functions for Core Chef Infra development

Added to portage

2026-01-15

claude-code - 2.1.8
Ebuild name:

dev-util/claude-code-2.1.8

Description

Claude Code - an agentic coding tool by Anthropic

Added to portage

2026-01-15

deno-bin - 2.6.5
Ebuild name:

dev-lang/deno-bin-2.6.5

Description

Modern runtime for JavaScript and TypeScript

Added to portage

2026-01-15

dict2xml - 1.7.8
Ebuild name:

dev-python/dict2xml-1.7.8

Description

Small utility to convert a python dictionary into an XML string

Added to portage

2026-01-15

django-polymorphic - 4.10.2
Ebuild name:

dev-python/django-polymorphic-4.10.2

Description

Seamless Polymorphic Inheritance for Django Models

Added to portage

2026-01-15

egl-gbm - 1.1.3
Ebuild name:

gui-libs/egl-gbm-1.1.3

Description

NVIDIA GBM EGL external platform library

Added to portage

2026-01-15

fastfetch - 2.57.1
Ebuild name:

app-misc/fastfetch-2.57.1

Description

Fast neofetch-like system information tool

Added to portage

2026-01-15

fido2 - 2.1.0
Ebuild name:

dev-python/fido2-2.1.0

Description

Python based FIDO 2.0 library

Added to portage

2026-01-15

jupyter-server-terminals - 0.5.4
Ebuild name:

dev-python/jupyter-server-terminals-0.5.4

Description

A Jupyter Server Extension Providing Terminals

Added to portage

2026-01-15

librt - 0.7.8
Ebuild name:

dev-python/librt-0.7.8

Description

Mypyc runtime library

Added to portage

2026-01-15

mattermost-desktop-bin - 6.0.3_rc1
Ebuild name:

net-im/mattermost-desktop-bin-6.0.3_rc1

Description

Mattermost Desktop application

Added to portage

2026-01-15

mothur - 1.48.2
Ebuild name:

sci-biology/mothur-1.48.2

Description

Suite of algorithms for ecological bioinformatics

Added to portage

2026-01-15

oidc-agent - 5.3.4
Ebuild name:

net-misc/oidc-agent-5.3.4

Description

Agent and tools for managing OpenID Connect tokens on the command line

Added to portage

2026-01-15

osm - 1.9
Ebuild name:

app-emacs/osm-1.9

Description

OpenStreetMap tile-based viewer for GNU Emacs

Added to portage

2026-01-15

pandas - 3.0.0_rc2
Ebuild name:

dev-python/pandas-3.0.0_rc2

Description

Powerful data structures for data analysis and statistics

Added to portage

2026-01-15

parser - 3.3.10.1
Ebuild name:

dev-ruby/parser-3.3.10.1

Description

A production-ready Ruby parser written in pure Ruby

Added to portage

2026-01-15

pixi - 0.63.0
Ebuild name:

dev-util/pixi-0.63.0

Description

A package management and workflow tool

Added to portage

2026-01-15

plotly - 6.5.2
Ebuild name:

dev-python/plotly-6.5.2

Description

Browser-based graphing library for Python

Added to portage

2026-01-15

prometheus-client - 0.24.1
Ebuild name:

dev-python/prometheus-client-0.24.1

Description

Python client for the Prometheus monitoring system

Added to portage

2026-01-15

regex - 2026.1.15
Ebuild name:

dev-python/regex-2026.1.15

Description

Alternative regular expression module to replace re

Added to portage

2026-01-15

resolv-replace - 0.2.0
Ebuild name:

dev-ruby/resolv-replace-0.2.0

Description

Replace Socket DNS with Resolv

Added to portage

2026-01-15

ruby - 3.2.10
Ebuild name:

dev-lang/ruby-3.2.10

Description

An object-oriented scripting language

Added to portage

2026-01-15

send2trash - 2.1.0
Ebuild name:

dev-python/send2trash-2.1.0

Description

Sends files to the Trash (or Recycle Bin)

Added to portage

2026-01-15

sphinx-pytest - 0.3.0
Ebuild name:

dev-python/sphinx-pytest-0.3.0

Description

Helpful pytest fixtures for Sphinx extensions

Added to portage

2026-01-15

synapse - 1.145.0
Ebuild name:

net-im/synapse-1.145.0

Description

Reference implementation of Matrix homeserver

Added to portage

2026-01-15

tifffile - 2026.1.14
Ebuild name:

dev-python/tifffile-2026.1.14

Description

Read and write TIFF files

Added to portage

2026-01-15

translate-toolkit - 3.18.1
Ebuild name:

dev-python/translate-toolkit-3.18.1

Description

Toolkit to convert between many translation formats

Added to portage

2026-01-15

trove-classifiers - 2026.1.14.14
Ebuild name:

dev-python/trove-classifiers-2026.1.14.14

Description

Canonical source for classifiers on PyPI (pypi.org)

Added to portage

2026-01-15

xcp - 0.24.2
Ebuild name:

sys-fs/xcp-0.24.2

Description

A 'cp' alternative with user-friendly feedback and performance optimisations

Added to portage

2026-01-15

yamllint - 1.38.0
Ebuild name:

dev-util/yamllint-1.38.0

Description

A linter for YAML files

Added to portage

2026-01-15

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