Configure sftp with /home chroot

While there are many resources dedicated to this very configuration, it was difficult to make any one of them work. The current configuration is CentOS 6.5. Here is the script to get a fully-functional sFTP server with chroot using the /home directories.

#!/bin/bash
# Description: Configure an sFTP server with chroot

#######################################################
# Install OpenSSH ("should already be installed")
#######################################################

yum install -y openssh-server openssh-clients

#######################################################
# Create an account and configure
#######################################################

groupadd sftponly
useradd -N -G sftponly -s /sbin/nologin user1
echo pass | passwd --stdin user1
chmod 755 /home/user1
chown root:root /home/user1
mkdir /home/user1/incoming
chown user1:sftponly /home/user1/incoming

#######################################################
# Modify sshd Configuration
#######################################################

cp /etc/ssh/sshd_config  /etc/ssh/sshd_config.original_copy

sed -i 's/^Subsystem/#Subsystem/' /etc/ssh/sshd_config
sed -i '/#Subsystem/i Subsystem       sftp     internal-sftp'  /etc/ssh/sshd_config
sed -i 's/^X11Forwarding/#X11Forwarding/' /etc/ssh/sshd_config

echo -e 'Match Group sftponly
\tChrootDirectory /home/%u
\tX11Forwarding no
\tAllowTcpForwarding no
\tForceCommand internal-sftp' >> /etc/ssh/sshd_config

service sshd restart

#######################################################
# SeLinux
#######################################################

setsebool -P ssh_chroot_rw_homedirs on
restorecon -vR /home

#Source(s)
# **** http://community.spiceworks.com/topic/300920-sftp-chroot-access-to-centos
# http://www.tecmint.com/install-openssh-server-in-linux/
# http://www.youtube.com/watch?v=DDCLmAodbPc
# http://cassjohnston.wordpress.com/2012/08/16/selinux-and-chrooted-sftp/
# https://wiki.archlinux.org/index.php/SFTP-chroot
# http://en.wikibooks.org/wiki/OpenSSH/Cookbook/SFTP