Fedora 20
Sponsored Link

SFTP only + Chroot2013/12/19

 
Configure SFTP only + Chroot.
Some users applied this settings can access only with SFTP and access to the permitted directories.
[1] For example, Set /home as the Chroot directory.
# create for SFTP group

[root@dlp ~]#
groupadd sftp_users

# apply to a user "cent" for SFTP only

[root@dlp ~]#
usermod -G sftp_users fedora

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

#
Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp
# add at the last

Match Group sftp_users
  X11Forwarding no
  AllowTcpForwarding no
  ChrootDirectory /home
  ForceCommand internal-sftp
[root@dlp ~]#
systemctl restart sshd.service

[2] Try to access with a user and make sure the settings.
[root@rx-7 ~]#
ssh fedora@10.0.0.30

fedora@10.0.0.30's password:
This service allows sftp connections only.
Connection to 10.0.0.30 closed.
# denyed normally
[root@rx-7 ~]#
sftp fedora@10.0.0.30

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

drwx------    3 500      500          4096 Dec 10 03:58 fedora
drwx------    2 501      502          4096 Dec 10 03:59 hirokun
sftp>
pwd

Remote working directory: /
sftp>
exit

Matched Content