Thursday, 3 October 2013

Access to CentOS - SFTP CHROOT

Trying to setup SFTP access to a file server as we need to share files with clients over the internet and I have no faith in plain FTP.

For now password authentication is fine but I would also like to use certificate authentication later.

I installed centos 6.4 and did the following:
root@servertechs1 [/]# yum -y install openssh-server openssh-clients

root@servertechs1 [/]# chkconfig sshd on

root@servertechs1 [/]# service sshd start

root@servertechs1 [/]# netstat -tulpn | grep :22

root@servertechs1 [/]# vi /etc/ssh/sshd_config

Replace
Subsystem sftp /usr/local/libexec/sftp-server

by

Subsystem sftp internal-sftp
root@servertechs1 [/]# vi /etc/ssh/sshd_config

Match group sftponly
ChrootDirectory /home/%u
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

root@servertechs1 [/]# groupadd sftponly
root@servertechs1 [/]# mkdir /home/test

root@servertechs1 [/]# useradd -g sftponly test

root@servertechs1 [/]# usermod -d / test

root@servertechs1 [/]# passwd test

root@servertechs1 [/]# chown test /home/test

root@servertechs1 [/]# chmod 760 test

Now I can SFTP in as root and "standard user" but I get "server unexpectedly closed connection" errors when attempting access via the "test" user.

Does anyone know what I have missed? I would really like to get this working on CentOS and stay away from MS as I'm trying to learn more about using Linux for as much as possible.

Tried turning off SELINUX but made no difference so I turned it back on again

 

No comments:

Post a Comment