Restrict SSH User Access to Certain Directory Using Chrooted Jail

Restrict SSH User Access to Certain Directory Using Chrooted Jail

1.Create a normal user.

2.Assign home directory
/raghuraman/tmp-sftp
3.The permission for raghuraman should be 755 and it should be owned by root.root.
4.The permission for tmp-sftp 755 and it should be owned by root.root.
5.The permission for /raghuraman/tmp-sftp/data should be 700 and it should be owned by the username raghuraman.raghuraman.
6.Modify the below changes in /etc/ssh/sshd_config as mentioned below
#Subsystem sftp /usr/lib/openssh/sftp-server - comment this line and make it as mentioned below.
Subsystem sftp internal-sftp
7.To Chroot a user add the below lines in sshd_config.
Match user raghuraman
ChrootDirectory /sftpusers/raghuraman
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
8.Restart SSH Service.
9.Check and verify it by login to the user via SFTP using the below command.
 sftp -oPort=2222 raghuraman@localhost or server IP.

Comments

Popular posts from this blog

How To Know Which Program To Use To Open An Unknown File Extension

Step By Step: Install and Configure Sensu + Grafana

Hosting a WordPress Blog with Amazon Linux