Version information
This version is compatible with:
- Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x
- Puppet >= 6.1.0 < 8.0.0
- , , ,
Start using this module
Add this module to your Puppetfile:
mod 'puppet-sftp_jail', '4.1.0'
Learn more about managing modules with a PuppetfileDocumentation
sftp_jail
Overview
This module leverages saz-ssh to more easily create a more robust-ier SFTP jail. Because of how SSH key pairs work in Linux, this module creates a home dir for each jail user, so that keys can be added to authorized_keys
and a homedir assigned without the nasty problem of the user escaping from the jail and landing in /
because of a mistaken homedir assignment.
Usage
Create sftp_jail::jail
resources to create jails. Each jail has one main user. If you need more then one user in a jail, create sftp_jail::user
resources for additional users and pass the correct jail
to it.
Reference
Table of Contents
Classes
sftp_jail
: Manage SFTP Jails
Defined types
sftp_jail::jail
: One SFTP Jail where users get "chrooted" intosftp_jail::user
: Adds a user's home directory to an SFTP jail.
Data types
Sftp_jail::File_name
: The name of a file. Not a full path!Sftp_jail::Sub_dirs
: A list of subdirectoriesSftp_jail::User_name
: Each user or group should have a unique alphanumeric name.
Classes
sftp_jail
Manage SFTP Jails
Parameters
The following parameters are available in the sftp_jail
class:
jails
Data type: Hash[String[1],Hash]
Jails to create. See sftp_jail::jail
for more details.
Default value: {}
users
Data type: Hash[String[1],Hash]
Users to create. See sftp_jail::user
for more details.
Default value: {}
chroot_base
Data type: Stdlib::Absolutepath
All jails are located in this directory.
Default value: '/chroot'
sub_dirs
Data type: Sftp_jail::Sub_dirs
A list of default subdirectories to ensure in every SFTP users home. Having a
default list of subdirectories is especially usefull, when a lot of users
need to have the exact same directory structure in there home. This list
can be overwritten or extended for each user seperatly.
see: sftp_jail::merge_subdirs
Default value: []
merge_subdirs
Data type: Boolean
Merge each users list of subdirectories (sftp_jail::user::sub_dirs
)
with the default list of subdirectories (sftp_jail::sub_dirs
)?
Default value: false
password_authentication
Data type: Enum['yes', 'no']
Default Password Authentication setting for SFTP jails. This will only impact SFTP users which are put in a chroot jail by this module.
Default value: 'no'
Defined types
sftp_jail::jail
A jail can have one or multiple users. With multiple users, they can share
some date via the /incomming
directory.
Examples
Single user
# The `sftp_jail::jail` resource creates a jail with a single home directory
# and an `incoming` directory. `incoming` is owned by the user and group
# provided when declaring the resource:
sftp_jail::jail { 'myjail':
user => 'bbriggs',
group => 'bbriggs',
}
Shared jail
# Sometimes, more than one user will need to access the same jail, but with
# different permissions. For instance, one may need read-write access while
# another is limited to read-only. In such a case, first create the jail with
# your write user and set up a match_group that redirects users. Again, the
# users and groups must already exist.
sftp_jail::jail { 'shared_jail':
user => 'writeuser',
group => 'writegroup',
match_group => 'sftpusers',
}
# Now add a user to your jail.
sftp_jail::user { 'readuser':
jail => '/chroot/shared_jail',
}
# To share write access to `/incoming`, set the `group` parameter of
# `sftp_jail::jail` to a group that is common to both users, such as the
# `sftpusers` group that you might use to redirect users into a jail.
Parameters
The following parameters are available in the sftp_jail::jail
defined type:
jail_name
Data type: Sftp_jail::File_name
The jails name.
Default value: $name
user
Data type: Sftp_jail::User_name
The user that will own the corresponding home directory in the jail, giving
the user a place to land. Also sets user ownership for /incoming
.
Default value: $name
group
Data type: Sftp_jail::User_name
The group that will own the corresponding home directory in the jail,
giving the user a place to land. Also sets group ownership for /incoming
.
Default value: $user
sub_dirs
Data type: Sftp_jail::Sub_dirs
This directory structure is enforced in the users Home.
Default value: $sftp_jail::sub_dirs
merge_subdirs
Data type: Boolean
Merge sub_dirs with the default sub_dirs?
Default value: $sftp_jail::merge_subdirs
match_group
Data type: Sftp_jail::User_name
Set the group that SSHd will look for when redirecting users to the jail.
Useful for shared jails. Defaults to the value of group
.
Default value: $group
password_authentication
Data type: Enum['yes', 'no']
Can the user login with a password? Public key authentication is generally recommended and has to be configured outside of the scope of this module.
Default value: $sftp_jail::password_authentication
sftp_jail::user
Used for shared jails to allow multiple users to write, or to allow one user to write and others to read-only.
Examples
Add user to the jail myjail
sftp_jail::user {'bob':
jail => '/chroot/myjail',
}
Add user to the jail myjail
and assign permissions
sftp_jail::user{'bob':
group => 'myjail_write',
jail => '/chroot/myjail',
}
Parameters
The following parameters are available in the sftp_jail::user
defined type:
jail
Data type: Stdlib::Absolutepath
The path of the jail's base directory, such as /chroot/myjail
. Do not
include a trailing slash.
user
Data type: Sftp_jail::User_name
The username that will own the corresponding home directory in the jail, giving the user a place to land.
Default value: $name
group
Data type: Sftp_jail::User_name
The group that will own the corresponding home directory in the jail.
Default value: $user
sub_dirs
Data type: Sftp_jail::Sub_dirs
This directory structure is enforced in the users Home.
Default value: $sftp_jail::sub_dirs
merge_subdirs
Data type: Boolean
Merge sub_dirs with the default sub_dirs?
Default value: $sftp_jail::merge_subdirs
Data types
Sftp_jail::File_name
The name of a file. Not a full path!
Alias of
Pattern[/\A[^\/\0]+\z/]
Sftp_jail::Sub_dirs
A list of subdirectories
Examples
A valid subdirectory
As!8df/[1qwEr/zXcv0'
Alias of
Array[Pattern[/\A([^\/\0]+\/*)*\z/]]
Sftp_jail::User_name
From useradd(8): It is usually recommended to only use usernames that begin with a lower case letter or an underscore, followed by lower case letters, digits, underscores, or dashes. They can end with a dollar sign. Usernames may only be up to 32 characters long.
Many installations also allow capitals or periods, for example to separate first and last names.
Alias of
Pattern[/\A[a-zA-Z_]([a-zA-Z.0-9_-]{0,30}[a-zA-Z0-9_$-])?\z/]
Changelog
All notable changes to this project will be documented in this file. Each new release typically also includes the latest modulesync defaults. These should not affect the functionality of the module.
v4.1.0 (2021-10-26)
Implemented enhancements:
- accept jails and users as class parameters #91 (nod0n)
- create sub directories in user homes #71 (nod0n)
v4.0.0 (2021-09-17)
Breaking changes:
- Drop Puppet 5/Add Puppet 7 support #86 (root-expert)
- the owning group of a users home directory defaults to $user, not to $name #78 (nod0n)
- Make $sftp_jail::user::jail a required parameter #77 (nod0n)
- Drop EL6 and Ubuntu 14.04, add Ubuntu 18.04 & Debian 10 #67 (ekohl)
Implemented enhancements:
- Add Debian 11 and Ubuntu 20.04 support #84 (nod0n)
- validate class and defined resource parameters #81 (nod0n)
- Allow jail creation without specifying a user #80 (nod0n)
- Add a default password authentication setting #74 (nod0n)
- Remove unused files and parameters #66 (ekohl)
Closed issues:
- check debian version #42
- Documentation in init.pp is still boilerplate from the module generate skeleton #13
Merged pull requests:
- Allow up-to-date dependencies #88 (smortex)
- move creation of user home from jail.pp to user.pp #87 (nod0n)
- Add puppet-lint-param-docs #82 (bastelfreak)
- Refactor
sftp_jail::jail
file resources #76 (nod0n) - Simplify default values in sftp_jail::jail #75 (nod0n)
- Add a short usage info in readme #73 (nod0n)
- Migrate documentation to Puppet strings #70 (nod0n)
- hiera.yaml #68 (nod0n)
- Use voxpupuli-acceptance #62 (ekohl)
v3.0.0 (2020-04-06)
Breaking changes:
- drop Puppet 4 / Require Puppet 5.5.8 #60 (bastelfreak)
Fixed bugs:
- 0775 permissions for /incoming #52 (cogliostro)
Closed issues:
- Group permissions for /incoming wrong #51
Merged pull requests:
- Allow saz/ssh 5.x and 6.x #59 (bastelfreak)
- Allow puppetlabs/stdlib 6.x #57 (dhoppe)
- Clean up acceptance spec helper #54 (ekohl)
- modulesync 2.8.0 and allow puppet 6.x #53 (bastelfreak)
v2.0.2 (2018-09-09)
Merged pull requests:
- allow saz/ssh 3.x and 4.x #49 (bastelfreak)
- allow puppetlabs/stdlib 5.x #47 (bastelfreak)
- Remove docker nodesets #43 (bastelfreak)
- drop EOL OSs; fix puppet version range #41 (bastelfreak)
- drop EOL OSs; fix puppet version range #39 (bastelfreak)
v2.0.1 (2018-03-29)
Closed issues:
- This module needs a labels sync! #14
Merged pull requests:
- Bump puppet to minimum supported version 4.10.0 #37 (bastelfreak)
v2.0.0 (2017-10-13)
Breaking changes:
- BREAKING: Drop puppet 3 support. Replace validate_* with datatypes in init #30 (bastelfreak)
Closed issues:
- concat::fragment error when initing jail #26
Merged pull requests:
- Add LICENSE file #28 (alexjfisher)
v1.1.0 (2017-01-12)
This is the last release with Puppet 3 support!
- Modulesync with latest Vox Pupuli defaults
- Improve fact mocking
- Move special facts into sepeate file
- Bump min version_requirement for Puppet + deps
2016-09-26 - Release 1.0.0
- Transfer to Vox Pupuli namespace
- Update tests for STRICT_VARS.
2016-05-29 - Release 0.1.3
- Fix duplicate declaration bug with ssh.
- Removed automatic inclusion of ssh class when sftp_jail is invoked (see previous bullet).
[YANKED] 2016-05-29 - Release 0.1.2
- Accidental/Empty release
2016-03-31 - Release 0.1.0
- Initial release
* This Changelog was automatically generated by github_changelog_generator
Dependencies
- saz/ssh (>= 2.9.1 < 8.0.0)
- puppetlabs/stdlib (>= 4.13.1 < 9.0.0)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.