OpenSSH : SFTP only + Chroot2025/10/31 |
|
Configure SFTP only + Chroot. |
|
| [1] | For example, Set [/home] as the Chroot directory. |
|
[root@dlp ~]#
vi /etc/ssh/sshd_config # line 125 : 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 systemctl restart sshd |
| [2] | Verify working with a user set SFTP only setting. |
|
[fedora@node01 ~]$ ssh dlp.srv.world
Enter passphrase for key '/home/fedora/.ssh/id_ed25519':
This service allows sftp connections only.
Connection to dlp.srv.world closed. # denied normally
[fedora@node01 ~]$ sftp dlp.srv.world Enter passphrase for key '/home/fedora/.ssh/id_ed25519': Connected to dlp.srv.world. sftp> ls -l drwx------ ? 1000 1000 162 Oct 31 09:20 fedora sftp> pwd Remote working directory: / sftp> exit |
| Sponsored Link |
|
|