OpenSSH : SFTP only + Chroot2024/12/19 |
|
Configure SFTP only + Chroot. |
|
| [1] | example, Set [/home] as the Chroot directory. |
|
[root@dlp ~]#
vi /etc/ssh/sshd_config # line 123 : comment out and add a line #Subsystem sftp /usr/libexec/openssh/sftp-server Subsystem sftp internal-sftp # add to last line Match Group sftp_users X11Forwarding no AllowTcpForwarding no ChrootDirectory /home ForceCommand internal-sftp
[root@dlp ~]#
systemctl restart sshd # for example, set [cent] user as SFTP only user [root@dlp ~]# usermod -aG sftp_users cent |
| [2] | Access the target user via SSH or SFTP and check that it works. |
|
[cent@node01 ~]$ ssh dlp.srv.world
Enter passphrase for key '/home/cent/.ssh/id_ed25519':
This service allows sftp connections only.
Connection to dlp.srv.world closed.
# denied normally
[cent@node01 ~]$ sftp dlp.srv.world Enter passphrase for key '/home/cent/.ssh/id_ed25519': Connected to dlp.srv.world. sftp> ls -l drwx------ ? 1000 1000 178 Dec 19 11:13 cent sftp> pwd Remote working directory: / sftp> exit |
| Sponsored Link |