Fedora 29
Sponsored Link

OpenSSH : SFTP only + Chroot2018/11/02

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

[root@dlp ~]#
groupadd sftp_users

# for example, apply to a user [fedora] for SFTP only

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

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

#Subsystem      sftp    /usr/libexec/openssh/sftp-server
Subsystem       sftp    internal-sftp

# add to the end

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

[2] Try to access with a user to verify settings.
[root@rx-7 ~]#
ssh fedora@

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

Connecting to
fedora@'s password:
ls -l

drwx------    3 1000     1000           95 Nov  1 15:58 fedora
drwx------    3 1001     1001           95 Nov  1 16:05 redhat

Remote working directory: /

Matched Content