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:

88154

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-05
derper - 1.102.2-r1
Ebuild name:

net-vpn/derper-1.102.2-r1

Description

DERP server for tailscale network

Added to portage

2026-09-05

libxml2 - 2.15.4
Ebuild name:

dev-libs/libxml2-2.15.4

Description

XML C parser and toolkit

Added to portage

2026-09-05

pdns-recursor - 5.4.6
Ebuild name:

net-dns/pdns-recursor-5.4.6

Description

The PowerDNS Recursor

Added to portage

2026-09-05

util-linux - 2.42.3
Ebuild name:

sys-apps/util-linux-2.42.3

Description

Various useful Linux utilities

Added to portage

2026-09-05

2026-09-04
7zip - 26.03
Ebuild name:

app-arch/7zip-26.03

Description

Free file archiver for extremely high compression

Added to portage

2026-09-04

QGnomePlatform - 0.9.2-r8
Ebuild name:

x11-themes/QGnomePlatform-0.9.2-r8

Description

Qt Platform Theme aimed to accommodate GNOME settings

Added to portage

2026-09-04

adwaita-qt - 1.4.2-r2
Ebuild name:

x11-themes/adwaita-qt-1.4.2-r2

Description

A style to bend Qt applications to look like they belong into GNOME

Added to portage

2026-09-04

boto3 - 1.43.88
Ebuild name:

dev-python/boto3-1.43.88

Description

The AWS SDK for Python

Added to portage

2026-09-04

botocore - 1.43.88
Ebuild name:

dev-python/botocore-1.43.88

Description

Low-level, data-driven core of boto 3

Added to portage

2026-09-04

django-otp - 1.7.2
Ebuild name:

dev-python/django-otp-1.7.2

Description

Django framework adding two-factor authentication using one-time passwo

Added to portage

2026-09-04

docker - 29.8.0
Ebuild name:

app-containers/docker-29.8.0

Description

The core functions you need to create Docker images and run Docker con

Added to portage

2026-09-04

docker-buildx - 0.37.0
Ebuild name:

app-containers/docker-buildx-0.37.0

Description

Docker CLI plugin for extended build capabilities with BuildKit

Added to portage

2026-09-04

docker-cli - 29.8.0
Ebuild name:

app-containers/docker-cli-29.8.0

Description

the command line binary for docker

Added to portage

2026-09-04

docker-compose - 5.5.1
Ebuild name:

app-containers/docker-compose-5.5.1

Description

Multi-container orchestration for Docker

Added to portage

2026-09-04

docker-credential-helpers - 0.9.9
Ebuild name:

app-containers/docker-credential-helpers-0.9.9

Description

Suite of programs to use native stores to keep Docke

Added to portage

2026-09-04

egl-gbm - 1.1.4
Ebuild name:

gui-libs/egl-gbm-1.1.4

Description

NVIDIA GBM EGL external platform library

Added to portage

2026-09-04

egl-wayland - 1.1.22
Ebuild name:

gui-libs/egl-wayland-1.1.22

Description

NVIDIA wayland EGL external platform library

Added to portage

2026-09-04

egl-wayland2 - 1.0.2
Ebuild name:

gui-libs/egl-wayland2-1.0.2

Description

NVIDIA wayland EGL external platform library, version 2

Added to portage

2026-09-04

egl-x11 - 1.0.6
Ebuild name:

gui-libs/egl-x11-1.0.6

Description

NVIDIA X11/XCB EGL external platform library

Added to portage

2026-09-04

etcd - 3.5.33
Ebuild name:

dev-db/etcd-3.5.33

Description

Highly-available key value store for shared configuration and service discovery

Added to portage

2026-09-04

github-cli - 2.100.0
Ebuild name:

dev-util/github-cli-2.100.0

Description

GitHub CLI

Added to portage

2026-09-04

gitlab-cli - 1.116.0
Ebuild name:

dev-util/gitlab-cli-1.116.0

Description

the official gitlab command line interface

Added to portage

2026-09-04

go - 1.27.1
Ebuild name:

dev-lang/go-1.27.1

Description

A concurrent garbage collected and typesafe programming language

Added to portage

2026-09-04

google-api-core - 2.36.0
Ebuild name:

dev-python/google-api-core-2.36.0

Description

Core Library for Google Client Libraries

Added to portage

2026-09-04

google-auth - 2.57.1
Ebuild name:

dev-python/google-auth-2.57.1

Description

Google Authentication Library

Added to portage

2026-09-04

googleapis-common-protos - 1.75.3
Ebuild name:

dev-python/googleapis-common-protos-1.75.3

Description

Python classes generated from the common protos in the g

Added to portage

2026-09-04

jj - 0.45.1
Ebuild name:

dev-vcs/jj-0.45.1

Description

Jujutsu - an experimental version control system

Added to portage

2026-09-04

libmirage - 3.3.3
Ebuild name:

dev-libs/libmirage-3.3.3

Description

CD and DVD image access library

Added to portage

2026-09-04

lice-el - 0.3
Ebuild name:

app-emacs/lice-el-0.3

Description

License and header template for GNU Emacs

Added to portage

2026-09-04

llama - 1.0.5
Ebuild name:

app-emacs/llama-1.0.5

Description

Compact syntax for short lambda

Added to portage

2026-09-04

load-relative - 1.3.1
Ebuild name:

app-emacs/load-relative-1.3.1

Description

Relative loads for Emacs Lisp files

Added to portage

2026-09-04

load-relative - 1.3.2
Ebuild name:

app-emacs/load-relative-1.3.2

Description

Relative loads for Emacs Lisp files

Added to portage

2026-09-04

log4e - 0.4.1
Ebuild name:

app-emacs/log4e-0.4.1

Description

Logging framework for GNU Emacs Lisp

Added to portage

2026-09-04

lookup - 1.99.96_pre20180209
Ebuild name:

app-emacs/lookup-1.99.96_pre20180209

Description

An interface to search CD-ROM books and network dictionaries

Added to portage

2026-09-04

lsp-docker - 1.0.0_p20240327
Ebuild name:

app-emacs/lsp-docker-1.0.0_p20240327

Description

Emacs library to leverage lsp-mode in the Docker environment

Added to portage

2026-09-04

lsp-java - 4.0
Ebuild name:

app-emacs/lsp-java-4.0

Description

Emacs Java IDE using Eclipse JDT Language Server

Added to portage

2026-09-04

lsp-mode - 10.0.0
Ebuild name:

app-emacs/lsp-mode-10.0.0

Description

Emacs client/library for the Language Server Protocol

Added to portage

2026-09-04

micawber - 0.8.0
Ebuild name:

dev-python/micawber-0.8.0

Description

A small library for extracting rich content from urls

Added to portage

2026-09-04

mongodb-compass-bin - 1.50.0
Ebuild name:

dev-db/mongodb-compass-bin-1.50.0

Description

GUI for MongoDB

Added to portage

2026-09-04

nvidia-vaapi-driver - 0.0.18
Ebuild name:

media-libs/nvidia-vaapi-driver-0.0.18

Description

A VA-API implemention using NVIDIA's NVDEC

Added to portage

2026-09-04

openvpn - 2.7.6
Ebuild name:

net-vpn/openvpn-2.7.6

Description

Robust and highly flexible tunneling application compatible with many OSes

Added to portage

2026-09-04

pixi - 0.79.0
Ebuild name:

dev-util/pixi-0.79.0

Description

A package management and workflow tool

Added to portage

2026-09-04

postfix - 3.12_pre20260901
Ebuild name:

mail-mta/postfix-3.12_pre20260901

Description

A fast and secure drop-in replacement for sendmail

Added to portage

2026-09-04

pytest-rerunfailures - 16.6.1
Ebuild name:

dev-python/pytest-rerunfailures-16.6.1

Description

pytest plugin to re-run tests to eliminate flaky failures

Added to portage

2026-09-04

setuptools-scm - 10.2.3
Ebuild name:

dev-python/setuptools-scm-10.2.3

Description

Manage versions by scm tags via setuptools

Added to portage

2026-09-04

slirp4netns - 1.3.5
Ebuild name:

app-containers/slirp4netns-1.3.5

Description

User-mode networking for unprivileged network namespaces

Added to portage

2026-09-04

snmp_exporter - 0.30.1
Ebuild name:

app-metrics/snmp_exporter-0.30.1

Description

Prometheus exporter for snmp metrics

Added to portage

2026-09-04

sqlglot - 30.18.0
Ebuild name:

dev-python/sqlglot-30.18.0

Description

An easily customizable SQL parser and transpiler

Added to portage

2026-09-04

terraform - 1.16.1
Ebuild name:

app-admin/terraform-1.16.1

Description

A tool for building, changing, and combining infrastructure safely

Added to portage

2026-09-04

urwid - 4.1.1
Ebuild name:

dev-python/urwid-4.1.1

Description

Curses-based user interface library for Python

Added to portage

2026-09-04

vcs-versioning - 2.3.4
Ebuild name:

dev-python/vcs-versioning-2.3.4

Description

Core VCS versioning functionality from setuptools-scm

Added to portage

2026-09-04

vdirsyncer - 0.21.0
Ebuild name:

dev-python/vdirsyncer-0.21.0

Description

Synchronize calendars and contacts

Added to portage

2026-09-04

vopono - 1.0.1
Ebuild name:

net-vpn/vopono-1.0.1

Description

Launch applications via VPN tunnels using temporary network namespaces

Added to portage

2026-09-04

yq-go - 4.53.6
Ebuild name:

app-misc/yq-go-4.53.6

Description

yq is a lightweight and portable command-line YAML, JSON and XML processor

Added to portage

2026-09-04

zmq-anyio - 0.4.1
Ebuild name:

dev-python/zmq-anyio-0.4.1

Description

Asynchronous API for ZMQ using AnyIO

Added to portage

2026-09-04

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