Add sftp jail.
This commit is contained in:
17
ansible/roles/sftp/files/sshd_config
Normal file
17
ansible/roles/sftp/files/sshd_config
Normal file
@@ -0,0 +1,17 @@
|
||||
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
|
||||
# but this is overridden so installations will only check .ssh/authorized_keys
|
||||
AuthorizedKeysFile .ssh/authorized_keys
|
||||
|
||||
# Only allow sftp users
|
||||
AllowUsers nochainstounlock
|
||||
ChrootDirectory /chroot
|
||||
|
||||
# override default of no subsystems
|
||||
Subsystem sftp /usr/libexec/sftp-server
|
||||
|
||||
# Example of overriding settings on a per-user basis
|
||||
Match User nochainstounlock
|
||||
X11Forwarding no
|
||||
AllowTcpForwarding no
|
||||
PermitTTY no
|
||||
ForceCommand internal-sftp
|
||||
1
ansible/roles/sftp/files/sshd_rc.conf
Normal file
1
ansible/roles/sftp/files/sshd_rc.conf
Normal file
@@ -0,0 +1 @@
|
||||
sshd_enable="YES"
|
||||
71
ansible/roles/sftp/tasks/common.yaml
Normal file
71
ansible/roles/sftp/tasks/common.yaml
Normal file
@@ -0,0 +1,71 @@
|
||||
- name: Create directories
|
||||
file:
|
||||
name: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: wheel
|
||||
loop:
|
||||
- /chroot
|
||||
- /chroot/readonly
|
||||
- /chroot/readwrite
|
||||
|
||||
- name: Create directories
|
||||
file:
|
||||
name: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: nochainstounlock
|
||||
group: nochainstounlock
|
||||
loop:
|
||||
- /chroot/readonly/downloads
|
||||
- /chroot/readonly/incomplete
|
||||
- /chroot/readwrite/downloads
|
||||
- /chroot/readwrite/incomplete
|
||||
|
||||
- name: Create directories
|
||||
file:
|
||||
name: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: 11235
|
||||
group: nochainstounlock
|
||||
loop:
|
||||
- /chroot/readonly/library
|
||||
- /chroot/readwrite/library
|
||||
|
||||
# - name: Install scripts
|
||||
# copy:
|
||||
# src: "files/{{ item.src }}"
|
||||
# dest: "{{ item.dest }}"
|
||||
# mode: 0755
|
||||
# owner: root
|
||||
# group: wheel
|
||||
# loop:
|
||||
# - src: foo.bash
|
||||
# dest: /usr/local/bin/foo
|
||||
|
||||
- name: Install Configuration
|
||||
copy:
|
||||
src: "files/{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: wheel
|
||||
loop:
|
||||
- src: sshd_config
|
||||
dest: /etc/ssh/sshd_config
|
||||
|
||||
# - name: Clone Source
|
||||
# git:
|
||||
# repo: "https://foo.bar/baz.git"
|
||||
# dest: /foo/bar
|
||||
# version: "v1.0.2"
|
||||
# force: true
|
||||
# diff: false
|
||||
|
||||
- import_tasks: tasks/freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- import_tasks: tasks/linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
||||
19
ansible/roles/sftp/tasks/freebsd.yaml
Normal file
19
ansible/roles/sftp/tasks/freebsd.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
- name: Create directories
|
||||
file:
|
||||
name: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: wheel
|
||||
loop:
|
||||
- /etc/rc.conf.d
|
||||
|
||||
- name: Install service configuration
|
||||
copy:
|
||||
src: "files/{{ item }}_rc.conf"
|
||||
dest: "/etc/rc.conf.d/{{ item }}"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: wheel
|
||||
loop:
|
||||
- sshd
|
||||
29
ansible/roles/sftp/tasks/linux.yaml
Normal file
29
ansible/roles/sftp/tasks/linux.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
# - name: Build aur packages
|
||||
# register: buildaur
|
||||
# become_user: "{{ build_user.name }}"
|
||||
# command: "aurutils-sync --no-view {{ item }}"
|
||||
# args:
|
||||
# creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*"
|
||||
# loop:
|
||||
# - foo
|
||||
|
||||
# - name: Update cache
|
||||
# when: buildaur.changed
|
||||
# pacman:
|
||||
# name: []
|
||||
# state: present
|
||||
# update_cache: true
|
||||
|
||||
# - name: Install packages
|
||||
# package:
|
||||
# name:
|
||||
# - foo
|
||||
# state: present
|
||||
|
||||
# - name: Enable services
|
||||
# systemd:
|
||||
# enabled: yes
|
||||
# name: "{{ item }}"
|
||||
# daemon_reload: yes
|
||||
# loop:
|
||||
# - foo.service
|
||||
2
ansible/roles/sftp/tasks/main.yaml
Normal file
2
ansible/roles/sftp/tasks/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- import_tasks: tasks/common.yaml
|
||||
# when: foo is defined
|
||||
Reference in New Issue
Block a user