Wednesday, October 14, 2015

SFTP with Chroot centos 6

    

Some users who are applied this settings can access only with SFTP and access to the permitted directories.
For example, Set /home as the Chroot directory.
# create a group for SFTP

[root@easylinux ~]# groupadd sftp_users

# apply to a user "clado" for SFTP only

[root@easylinux ~]# usermod -G sftp_users clado

[root@easylinux ~]# vi /etc/ssh/sshd_config
# line 132: comment out and add a line like below

#
Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp
# add follows to the end

Match Group sftp_users
  X11Forwarding no
  AllowTcpForwarding no
  ChrootDirectory /home
  ForceCommand internal-sftp
[root@easylinux ~]# /etc/rc.d/init.d/sshd restart

[2]     Try to access with a user and make sure the settings.
[root@cladoserver ~]# ssh clado@10.0.0.30

clado@10.0.0.30's password:
This service allows sftp connections only.
Connection to 10.0.0.30 closed.# denied normally
[root@cladoserver ~]# sftp clado@10.0.0.30

Connecting to 10.0.0.30...
clado@10.0.0.30's password:
sftp> ls -l

drwx------    3 1000     1000         4096 Jul  9 12:06 clado
drwx------    2 1001     1001           59 Jul  8 22:06 hirokun

sftp> pwd

Remote working directory: /
sftp> exit


No comments:

Post a Comment