Set permission to SFTP users
Posted: 02 Feb 2021, 07:11
Hi, I wanna customize some user preferences. I would like set that ftp users can’t navigate the root of a given folder. I tried to modify the sshd_config file in /etc/ssh and in a certain way it worked. The only problem is that on every reboot the /home/ftpuser folder must be owner changed from ftpuser to root in order to make accessible the ftp account, also permissions must be set with chmod. I don’t know why is necessary this procedure but it works. The main problem is that I wrote a little script to do this on every reboot but it doesn’t work (same on crontab); the same line of code from ssh session makes everything working. How it’s possible? I was logged with root obviously. So, How can I manage ftp user accessibility?
These are the lines modified from sshd_config file
After that I restarted ssh services
This is the startup script placed into /etc/init.d (with symlink to sc.d)
These are the lines modified from sshd_config file
Code: Select all
Subsystem sftp internal-sftp
Match User ftpuser
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
This is the startup script placed into /etc/init.d (with symlink to sc.d)
Code: Select all
#!/bin/bash
chown root:root /home/ftpuser
chmod 755 /home/ftpuser