Set permission to SFTP users

SMB, NFS, FTP, web file manager and Rsync server.
Locked
User avatar
fabiobiscia
Posts: 24
Joined: 08 Jan 2021, 08:28

Set permission to SFTP users

Post by fabiobiscia »

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

Code: Select all

Subsystem sftp internal-sftp

Match User ftpuser
    ChrootDirectory %h
    X11Forwarding no
    AllowTcpForwarding no
    ForceCommand internal-sftp
After that I restarted ssh services

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
User avatar
RyanYang
TM Support
Posts: 1141
Joined: 01 Dec 2020, 11:50
China

Re: Set permission to SFTP users

Post by RyanYang »

Hello,
You can use the touch command in the /etc/sc.d directory to create an empty file with the same name as your script.
sh.png
Note: script.sh refers to your script, you need to replace it with your script name.
To contact our team, please send email to following addresses, remember to replace (at) with @
Technical team: support(at)terra-master.com (for technical support)
Service team: service(at)terra-master.com (for purchasing, return, replacement)
User avatar
fabiobiscia
Posts: 24
Joined: 08 Jan 2021, 08:28

Re: Set permission to SFTP users

Post by fabiobiscia »

Unfortunately this doesn’t work, the same line of code executed from terminal works but placed into /etc/init.d and a text file into /etc/sc.d doesn’t works. Chown requires special privileges? Sudo command doesn’t work.
User avatar
RyanYang
TM Support
Posts: 1141
Joined: 01 Dec 2020, 11:50
China

Re: Set permission to SFTP users

Post by RyanYang »

Hi,
Is the file you created in /etc/sc.d empty?
Is the name of the empty file the same as the name of the script you put in /etc/init.d?
You do not need to use the Sudo command after logging in as root.
To log in to other users, you can try to add other users to the admin group and enable user SSH login in the advanced settings of the edit user
To contact our team, please send email to following addresses, remember to replace (at) with @
Technical team: support(at)terra-master.com (for technical support)
Service team: service(at)terra-master.com (for purchasing, return, replacement)
User avatar
fabiobiscia
Posts: 24
Joined: 08 Jan 2021, 08:28

Re: Set permission to SFTP users

Post by fabiobiscia »

I have followed your steps but no way to make it works. But there is a news. After a completely fresh install of SO the same line of code works in crontab. How is it possible? It’s a good thing run the script every X minutes?
User avatar
RyanYang
TM Support
Posts: 1141
Joined: 01 Dec 2020, 11:50
China

Re: Set permission to SFTP users

Post by RyanYang »

Hello,
If you cannot use this method, there is no way for the time being.
Did you use crontab -e to reset it after reinstalling the system?
If so, the script will always run unless the device is restarted. Maybe you can set the rest time in the script.
This effect depends on your script. For example, if it is a script that is copied automatically and repeatedly, the usage of the hard disk will increase.
To contact our team, please send email to following addresses, remember to replace (at) with @
Technical team: support(at)terra-master.com (for technical support)
Service team: service(at)terra-master.com (for purchasing, return, replacement)
User avatar
fabiobiscia
Posts: 24
Joined: 08 Jan 2021, 08:28

Re: Set permission to SFTP users

Post by fabiobiscia »

Okok, I understand. I will try alternative solutions
Locked

Return to “File Services”