OpenSSH : SFTP only + Chroot2022/01/07 |
Configure SFTP only + Chroot.
Some users who are applied this setting can access only with SFTP and also applied chroot directory. |
|
[1] | For 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 the end
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] | Verify working with a user set SFTP only setting. |
[cent@node01 ~]$
[cent@node01 ~]$ ssh dlp.srv.world Enter passphrase for key '/home/cent/.ssh/id_rsa': This service allows sftp connections only. Connection to dlp.srv.world closed. # denied normally
sftp dlp.srv.world Enter passphrase for key '/home/cent/.ssh/id_rsa': Connected to dlp.srv.world. sftp> ls -l drwx------ 3 1000 1000 95 Jan 7 02:08 centsftp> pwd Remote working directory: / sftp> exit |
Sponsored Link |