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:

58401

userrating:

average rating: 1.5 (4 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
rate this article:
current rating: average rating: 1.2 (48 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back



Support us on Content Nation

New Packages

- as rdf newsfeed
- as rss newsfeed
- as Atom newsfeed
2021-07-26
gentoo-sources - 5.10.53
Ebuild name:

sys-kernel/gentoo-sources-5.10.53

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2021-07-26

gentoo-sources - 5.13.5
Ebuild name:

sys-kernel/gentoo-sources-5.13.5

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2021-07-26

gentoo-sources - 5.4.135
Ebuild name:

sys-kernel/gentoo-sources-5.4.135

Description

Full sources including the Gentoo patchset for the . kernel tree

Added to portage

2021-07-26

pandas - 1.3.1
Ebuild name:

dev-python/pandas-1.3.1

Description

Powerful data structures for data analysis and statistics

Added to portage

2021-07-26

rabbitmq_exporter - 0
Ebuild name:

acct-user/rabbitmq_exporter-0

Description

A user for app-metrics/rabbitmq_exporter

Added to portage

2021-07-26

snmp_exporter - 0
Ebuild name:

acct-user/snmp_exporter-0

Description

A user for app-metrics/snmp_exporter

Added to portage

2021-07-26

stardict-quick-jpn-eng - 2.4.2
Ebuild name:

app-dicts/stardict-quick-jpn-eng-2.4.2

Description

Added to portage

2021-07-26

stardict-quick-ru-en - 2.4.2
Ebuild name:

app-dicts/stardict-quick-ru-en-2.4.2

Description

Quick but still useful Russian to English dictionary

Added to portage

2021-07-26

xfce4-dev-tools - 4.17.0
Ebuild name:

dev-util/xfce4-dev-tools-4.17.0

Description

A set of scripts and m4/autoconf macros that ease build system main

Added to portage

2021-07-26

2021-07-25
PAR-Dist - 0.510.0
Ebuild name:

dev-perl/PAR-Dist-0.510.0

Description

Create and manipulate PAR distributions

Added to portage

2021-07-25

PBKDF2-Tiny - 0.5.0-r2
Ebuild name:

dev-perl/PBKDF2-Tiny-0.5.0-r2

Description

Minimalist PBKDF2 (RFC 2898) with HMAC-SHA1 or HMAC-SHA2

Added to portage

2021-07-25

PBS-Client - 0.110.0-r1
Ebuild name:

dev-perl/PBS-Client-0.110.0-r1

Description

Perl interface to submit jobs to PBS (Portable Batch System)

Added to portage

2021-07-25

PDF-API2 - 2.40.0
Ebuild name:

dev-perl/PDF-API2-2.40.0

Description

Facilitates the creation and modification of PDF files

Added to portage

2021-07-25

PDF-Builder - 3.23.0
Ebuild name:

dev-perl/PDF-Builder-3.23.0

Description

Facilitates the creation and modification of PDF files

Added to portage

2021-07-25

PDF-Create - 1.460.0
Ebuild name:

dev-perl/PDF-Create-1.460.0

Description

Create PDF documents in Perl

Added to portage

2021-07-25

Params-Validate - 1.300.0
Ebuild name:

dev-perl/Params-Validate-1.300.0

Description

Flexible system for validation of method/function call parameters

Added to portage

2021-07-25

Params-ValidationCompiler - 0.300.0
Ebuild name:

dev-perl/Params-ValidationCompiler-0.300.0

Description

Build an optimized subroutine parameter validator once,

Added to portage

2021-07-25

Parse-ExuberantCTags - 1.20.0-r2
Ebuild name:

dev-perl/Parse-ExuberantCTags-1.20.0-r2

Description

Efficiently parse exuberant ctags files

Added to portage

2021-07-25

Parse-RecDescent - 1.967.15-r1
Ebuild name:

dev-perl/Parse-RecDescent-1.967.15-r1

Description

Generate Recursive-Descent Parsers

Added to portage

2021-07-25

Parse-Syslog - 1.100.0-r2
Ebuild name:

dev-perl/Parse-Syslog-1.100.0-r2

Description

Parse - Parse Unix syslog files

Added to portage

2021-07-25

Parse-Yapp - 1.210.0-r1
Ebuild name:

dev-perl/Parse-Yapp-1.210.0-r1

Description

Compiles yacc-like LALR grammars to generate Perl OO parser modules

Added to portage

2021-07-25

Passwd-Linux - 1.300.0-r1
Ebuild name:

dev-perl/Passwd-Linux-1.300.0-r1

Description

Perl module for manipulating the passwd and shadow files

Added to portage

2021-07-25

Passwd-Unix - 0.710.0-r1
Ebuild name:

dev-perl/Passwd-Unix-0.710.0-r1

Description

access to standard unix passwd files

Added to portage

2021-07-25

PatchReader - 0.9.6-r2
Ebuild name:

dev-perl/PatchReader-0.9.6-r2

Description

Module for reading diff-compatible patch files

Added to portage

2021-07-25

Path-Class - 0.370.0-r1
Ebuild name:

dev-perl/Path-Class-0.370.0-r1

Description

Cross-platform path specification manipulation

Added to portage

2021-07-25

Path-FindDev - 0.5.3-r1
Ebuild name:

dev-perl/Path-FindDev-0.5.3-r1

Description

Find a development path somewhere in an upper hierarchy

Added to portage

2021-07-25

Path-IsDev - 1.1.3-r1
Ebuild name:

dev-perl/Path-IsDev-1.1.3-r1

Description

Determine if a given Path resembles a development source tree

Added to portage

2021-07-25

Path-Tiny - 0.118.0
Ebuild name:

dev-perl/Path-Tiny-0.118.0

Description

File path utility

Added to portage

2021-07-25

apache - 2.4.48-r3
Ebuild name:

www-servers/apache-2.4.48-r3

Description

The Apache Web Server

Added to portage

2021-07-25

bashate - 2.0.0
Ebuild name:

dev-python/bashate-2.0.0

Description

A pep8 equivalent for bash scripts

Added to portage

2021-07-25

binutils - 2.36.1-r2
Ebuild name:

sys-devel/binutils-2.36.1-r2

Description

Tools necessary to build programs

Added to portage

2021-07-25

binutils-hppa64 - 2.36.1-r2
Ebuild name:

sys-devel/binutils-hppa64-2.36.1-r2

Description

Tools necessary to build programs

Added to portage

2021-07-25

binutils-libs - 2.36.1-r2
Ebuild name:

sys-libs/binutils-libs-2.36.1-r2

Description

Core binutils libraries (libbfd, libopcodes, libiberty) for extern

Added to portage

2021-07-25

call-stack - 0.3.0
Ebuild name:

dev-haskell/call-stack-0.3.0

Description

Use GHC call-stacks in a backward compatible way

Added to portage

2021-07-25

diskimage-builder - 3.13.0
Ebuild name:

app-emulation/diskimage-builder-3.13.0

Description

Golden Disk Image builder.

Added to portage

2021-07-25

emacs - 25.3-r11
Ebuild name:

app-editors/emacs-25.3-r11

Description

The extensible, customizable, self-documenting real-time display editor

Added to portage

2021-07-25

emacs - 26.3-r6
Ebuild name:

app-editors/emacs-26.3-r6

Description

The extensible, customizable, self-documenting real-time display editor

Added to portage

2021-07-25

emacs - 27.2-r4
Ebuild name:

app-editors/emacs-27.2-r4

Description

The extensible, customizable, self-documenting real-time display editor

Added to portage

2021-07-25

fritzconnection - 1.6.0
Ebuild name:

dev-python/fritzconnection-1.6.0

Description

Lib/tool to communicate with AVM FRITZ devices using TR-064 protoc

Added to portage

2021-07-25

ftp - 0-r3
Ebuild name:

acct-user/ftp-0-r3

Description

File Transfer Protocol (FTP) server user

Added to portage

2021-07-25

gauche - 0.9.10-r1
Ebuild name:

dev-scheme/gauche-0.9.10-r1

Description

A Unix system friendly Scheme Interpreter

Added to portage

2021-07-25

gauche - 0.9.9-r1
Ebuild name:

dev-scheme/gauche-0.9.9-r1

Description

A Unix system friendly Scheme Interpreter

Added to portage

2021-07-25

glob - 0.10.1
Ebuild name:

dev-haskell/glob-0.10.1

Description

Globbing library

Added to portage

2021-07-25

goobook - 3.5.1-r2
Ebuild name:

app-misc/goobook-3.5.1-r2

Description

Access your Google contacts from the command line

Added to portage

2021-07-25

hdbc-postgresql - 2.5.0.0
Ebuild name:

dev-haskell/hdbc-postgresql-2.5.0.0

Description

PostgreSQL driver for HDBC

Added to portage

2021-07-25

http-reverse-proxy - 0.6.0
Ebuild name:

dev-haskell/http-reverse-proxy-0.6.0

Description

Reverse proxy HTTP requests, either over raw sockets or with W

Added to portage

2021-07-25

hunit - 1.6.2.0
Ebuild name:

dev-haskell/hunit-1.6.2.0

Description

A unit testing framework for Haskell

Added to portage

2021-07-25

lens - 4.19.2-r2
Ebuild name:

dev-haskell/lens-4.19.2-r2

Description

Lenses, Folds and Traversals

Added to portage

2021-07-25

libgudev - 236
Ebuild name:

dev-libs/libgudev-236

Description

GObject bindings for libudev

Added to portage

2021-07-25

minecraft-launcher - 928-r2
Ebuild name:

games-action/minecraft-launcher-928-r2

Description

An open-world game whose gameplay revolves around breaking a

Added to portage

2021-07-25

mono-traversable-instances - 0.1.1.0
Ebuild name:

dev-haskell/mono-traversable-instances-0.1.1.0

Description

Extra typeclass instances for mono-traversable

Added to portage

2021-07-25

networkmanager-l2tp - 1.8.2-r1
Ebuild name:

net-vpn/networkmanager-l2tp-1.8.2-r1

Description

NetworkManager L2TP plugin

Added to portage

2021-07-25

networkmanager-l2tp - 1.8.6
Ebuild name:

net-vpn/networkmanager-l2tp-1.8.6

Description

NetworkManager L2TP plugin

Added to portage

2021-07-25

nonce - 1.0.7-r1
Ebuild name:

dev-haskell/nonce-1.0.7-r1

Description

Generate cryptographic nonces

Added to portage

2021-07-25

pip - 21.2.1
Ebuild name:

dev-python/pip-21.2.1

Description

Installs python packages -- replacement for easy_install

Added to portage

2021-07-25

plex-media-server - 1.23.5.4862
Ebuild name:

media-tv/plex-media-server-1.23.5.4862

Description

Free media library that is intended for use with a plex clie

Added to portage

2021-07-25

pointed - 5.0.2
Ebuild name:

dev-haskell/pointed-5.0.2

Description

Pointed and copointed data

Added to portage

2021-07-25

postgresql - 10.17-r1
Ebuild name:

dev-db/postgresql-10.17-r1

Description

PostgreSQL RDBMS

Added to portage

2021-07-25

postgresql - 9.5.25-r1
Ebuild name:

dev-db/postgresql-9.5.25-r1

Description

PostgreSQL RDBMS

Added to portage

2021-07-25

postgresql - 9.6.22-r1
Ebuild name:

dev-db/postgresql-9.6.22-r1

Description

PostgreSQL RDBMS

Added to portage

2021-07-25

project-template - 0.2.1.0
Ebuild name:

dev-haskell/project-template-0.2.1.0

Description

Specify Haskell project templates and generate files

Added to portage

2021-07-25

protobuf-cucumber - 3.10.8-r1
Ebuild name:

dev-util/protobuf-cucumber-3.10.8-r1

Description

Google Protocol Buffers serialization and RPC implementation f

Added to portage

2021-07-25

puppetdb-termini - 7.5.0
Ebuild name:

dev-ruby/puppetdb-termini-7.5.0

Description

Library needed to connect puppet to puppetdb

Added to portage

2021-07-25

python-dotenv - 0.19.0
Ebuild name:

dev-python/python-dotenv-0.19.0

Description

Manage .env files

Added to portage

2021-07-25

reducers - 3.12.3-r1
Ebuild name:

dev-haskell/reducers-3.12.3-r1

Description

Semigroups, specialized containers and a general map/reduce framewor

Added to portage

2021-07-25

regex-tdfa - 1.3.1.1
Ebuild name:

dev-haskell/regex-tdfa-1.3.1.1

Description

Pure Haskell Tagged DFA Backend for

Added to portage

2021-07-25

shadow - 4.9-r1
Ebuild name:

sys-apps/shadow-4.9-r1

Description

Utilities to deal with user accounts

Added to portage

2021-07-25

spidermonkey - 52.9.1_pre1-r3
Ebuild name:

dev-lang/spidermonkey-52.9.1_pre1-r3

Description

Stand-alone JavaScript C++ library

Added to portage

2021-07-25

spidermonkey - 60.5.2_p0-r5
Ebuild name:

dev-lang/spidermonkey-60.5.2_p0-r5

Description

Stand-alone JavaScript C++ library

Added to portage

2021-07-25

stardict-quick-jpn-eng - 2.4.2
Ebuild name:

app-dicts/stardict-quick-jpn-eng-2.4.2

Description

Added to portage

2021-07-25

stardict-quick-ru-en - 2.4.2
Ebuild name:

app-dicts/stardict-quick-ru-en-2.4.2

Description

Quick but still useful Russian to English dictionary

Added to portage

2021-07-25

tdb - 1.4.5
Ebuild name:

sys-libs/tdb-1.4.5

Description

Simple database API

Added to portage

2021-07-25

vanilla-sources - 5.10.53
Ebuild name:

sys-kernel/vanilla-sources-5.10.53

Description

Full sources for the Linux kernel

Added to portage

2021-07-25

vanilla-sources - 5.13.5
Ebuild name:

sys-kernel/vanilla-sources-5.13.5

Description

Full sources for the Linux kernel

Added to portage

2021-07-25

vanilla-sources - 5.4.135
Ebuild name:

sys-kernel/vanilla-sources-5.4.135

Description

Full sources for the Linux kernel

Added to portage

2021-07-25

wps-office - 11.1.0.10161-r1
Ebuild name:

app-office/wps-office-11.1.0.10161-r1

Description

WPS Office is an office productivity suite

Added to portage

2021-07-25

xdg - 5.1.1
Ebuild name:

dev-python/xdg-5.1.1

Description

Implementation of the XDG Base Directory Specification in Python

Added to portage

2021-07-25

yesod-auth - 1.6.10.3
Ebuild name:

dev-haskell/yesod-auth-1.6.10.3

Description

Authentication for Yesod

Added to portage

2021-07-25

zzuf - 0.15-r2
Ebuild name:

app-forensics/zzuf-0.15-r2

Description

Transparent application input fuzzer

Added to portage

2021-07-25

rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2020 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 58.0 ms