Новости:

Форуму исполнилось 12 лет!

Мы в матрице .
Мы в телеге .

Главное меню

Chroot ssh настройка

Автор kvip, 11 июля 2014, 10:46:13

« назад - далее »

0 Пользователи и 1 гость просматривают эту тему.

kvip

Решил узнать, как ограничить пользователя ssh в одном каталоге и у меня появились проблемы.

Мой конфиг:
# override default of no subsystems
Subsystem sftp /usr/libexec/sftp-server

# Example of overriding settings on a per-user basis
Match User test1
  ChrootDirectory /opt/hd1/test1
  X11Forwarding no
  AllowTcpForwarding no
  ForceCommand cvs server


Пользователя создавал:
useradd -d /opt/hd1/test1 -s /bin/false test1
mkdir /opt/hd1/test1
chown test1 /opt/hd1/test1


После чего рестарт демона
/etc/rc.d/rc.sshd restart

Под рутом я логинюсь нормально, а вот под этим пользователем не получается, putty выдает лог:
Network error: Software caused connection abort

Что я делаю не так?

bormant

/bin/flase в качестве оболочки (шелла) не вызывает подозрений?

kvip

Тоже думал, что в этом проблема, но пробовал /bin/bash и /bin/sh и ни чего не изменилось.

bormant

Предположу, что проблема в неподготовленном, пустом /opt/hd1/test1. Оттуда не удается запустить шелл, поскольку его (и зависимостей) там просто нет. Тот же результат получите, попытавшись выполнить
$ chroot /opt/hd1/test1

kvip

chroot: failed to run command '/bin/bash': No such file or directory


bormant

#5
Выходит, угадал :-)
Посмотрите, что нужно этому пользователю, слинкуйте (или скопируйте) всё необходимое по своим местам. См. man sshd_config:
Цитировать
ChrootDirectory
Specifies a path to chroot(2) to after authentication.  This path, and all its components, must be root-owned directories that are not writable by any other user or group.

The path may contain the following tokens that are expanded at runtime once the connecting user has been authenticated: %% is replaced by a literal '%', %h is replaced by the home directory of the user being authenticated, and %u is replaced by the username of that user.

The ChrootDirectory must contain the necessary files and directories to support the users' session.  For an interactive session this requires at least a shell, typically sh(1), and basic /dev nodes such as null(4), zero(4), stdin(4), stdout(4), stderr(4), arandom(4) and tty(4) devices.  For file transfer sessions using ``sftp'', no additional configuration of the environment is necessary if the in-process sftp server is used (see Subsystem for details).

kvip


Graf

#7
ТУТ описывают как для Дебиана сделать. Сам не пробовал, но думаю в слаке тоже получится :)

ЗЫ: в комментариях говорят, получилось :)