# irrigate-sftp

This cookbook is to setup a jailed chroot sftp server with password authentication and using S3 as storage.

This will do the following:
  1. Installs and sets up s3fs to mount an S3 directory (Includes aws credentials and an fstab entry)
  2. Creates user and passwords from encrypted data bags
  3. Configures sshd_config to jail standard end users to their directory and an option enabled for admin users to administer all directories

## Supported Plaforms

CentOS 7+

## Attributes

All sftp attributes can be overridden in roles as needed.

<table>
  <tr>
    <th>Key</th>
    <th>Type</th>
    <th>Description</th>
    <th>Default</th>
  </tr>
  <tr>
    <td><tt>['sftp']['sftp_root_directory']</tt></td>
    <td>String</td>
    <td>Location of the sftp root directory</td>
    <td><tt>/mnt/sftp</tt></td>
  </tr>
  <tr>
    <td><tt>['sftp']['sftp_user_group']</tt></td>
    <td>String</td>
    <td>Name of the sftp group</td>
    <td><tt>sftp</tt></td>
  </tr>
  <tr>
    <td><tt>['sftp']['device_mount']</tt></td>
    <td>String</td>
    <td>Name of device to mount.</td>
    <td><tt>If using s3fs: s3fs#{bucket_name}</tt></td>
  </tr>
    <tr>
    <td><tt>['sftp']['mount_options']</tt></td>
    <td>String</td>
    <td>Options for mounting directory</td>
    <td><tt>_netdev,allow_other,enable_noobj_cache,enable_content_md5,mp_umask=022,gid=1001</tt></td>
  </tr>
</table>

## Usage

### irrigate-sftp::default

Include `irrigate-sftp` in your node's `run_list`:
```json
{
	"run_list": [
	  "recipe[irrigate-sftp::default]"
	]
}
```

Using AWS and storing user/pass credentials, this has a couple of required data bags:
```
sftp_user_credentials
sftp_aws_credentials
```

The following admin users need to be in the databag in order to create there accounts:
```
node['sftp']['sftp_rsbookpub_user']
node['sftp']['sftp_dtmvadmin_user']
```

## License and Authors

Author:: Jerry Carrion (<jcarrion@theorchard.com>)
