buluma.ssh_chroot_jail

Ansible 角色 ssh_chroot_jail

简单的 SSH chroot 监狱管理。

GitHub 版本 问题 拉取请求 下载量
github 版本 问题 拉取请求 Ansible 角色

示例 Playbook

这个示例来自 molecule/default/converge.yml,并在每次推送、拉取请求和发布时进行测试。

---
- name: 汇聚
  hosts: all
  become: true

  vars:
    ssh_chroot_l2chroot_path: /usr/bin/l2chroot
    ssh_chroot_jail_users:
      - name: foo
        home: /home/foo
        shell: /bin/bash

  roles:
    - role: buluma.ssh_chroot_jail

机器需要准备好。在 CI 中使用 molecule/default/prepare.yml 来完成:

---
- name: 准备
  hosts: all
  become: yes
  gather_facts: no

  roles:
    - role: buluma.bootstrap

另请查看完整的解释和示例,以了解如何使用这些角色。

角色变量

变量的默认值设置在 defaults/main.yml 中:

---
ssh_chroot_jail_path: /var/jail

ssh_chroot_jail_group_name: ssh_jailed

ssh_chroot_jail_users: []

ssh_chroot_jail_dirs:
  - bin
  - dev
  - etc
  - lib
  - lib64
  - usr/bin
  - usr/lib
  - usr/lib64
  - home

# 可以包括类型:c, b, p
# c = 字符设备(无缓冲)[默认]
# b = 块设备(缓冲)
# p = FIFO 设备
# 其他类型可能导致 mknod 或 systemd-tmpfiles 出错
ssh_chroot_jail_devs:
  - {dev: 'null', major: '1', minor: '3'}
  - {dev: 'random', major: '5', minor: '0'}
  - {dev: 'urandom', major: '1', minor: '5'}
  - {dev: 'zero', major: '1', minor: '8'}

ssh_chroot_tmpfiles_conf_path: /etc/tmpfiles.d/ssh-chroot.conf

ssh_chroot_bins:
  - /bin/cp
  - /bin/sh
  - /bin/bash
  - /bin/ls
  - /bin/rm
  - /bin/cat
  - /bin/grep
  - /bin/sed
  - /bin/chmod
  - /bin/chown
  - /bin/ed
  - /bin/nano
  - /usr/bin/tail
  - /usr/bin/head
  - /usr/bin/awk
  - /usr/bin/wc
  - /usr/bin/sort
  - /usr/bin/uniq
  - /usr/bin/cut
  - /usr/bin/scp
  - /usr/bin/tee
  - /usr/bin/touch
  - /usr/bin/vim
  - /usr/bin/vi
  - /usr/bin/dircolors
  - /usr/bin/tput
  - /usr/bin/free
  - /usr/bin/top
  - /usr/bin/find
  - bin: /usr/bin/which
    l2chroot: false
  - /usr/bin/id
  - /usr/bin/whoami
  - /usr/bin/groups
  # 还可以设置模式,例如设置为 setuid 或设置不同权限。
  # - bin: /bin/ping
  #   mode: 4755

ssh_chroot_l2chroot_template: l2chroot.j2
ssh_chroot_l2chroot_path: /usr/local/bin/l2chroot

ssh_chroot_copy_extra_items:
  - /etc/hosts
  - /etc/passwd
  - /etc/group
  - /etc/ld.so.cache
  - /etc/ld.so.conf
  - /etc/nsswitch.conf

ssh_chroot_sshd_chroot_jail_config: |
  Match group {{ ssh_chroot_jail_group_name }}
      ChrootDirectory {{ ssh_chroot_jail_path }}
      X11Forwarding no
      AllowTcpForwarding no

ssh_chroot_jail_dirs_recurse: true

要求

使用角色的状态

以下角色用于准备系统。您可以以其他方式准备您的系统。

需求 GitHub 版本
buluma.bootstrap Ansible Molecule 版本

上下文

此角色是许多兼容角色的一部分。有关更多信息,请查看这些角色的文档

以下是相关角色的概述:

依赖关系

兼容性

此角色已在这些容器镜像上进行测试:

容器 标签
Debian 所有
Ubuntu 所有
Kali 所有

所需的最低 Ansible 版本为 2.12,测试已完成:

  • 之前的版本。
  • 当前版本。
  • 开发版本。

如果您发现问题,请在 GitHub 中登记。

变更日志

角色历史

许可证

Apache-2.0

作者信息

Shadow Walker

安装
ansible-galaxy install buluma.ssh_chroot_jail
许可证
apache-2.0
下载
2.9k
拥有者
DevOps Engineer