Answer the question
In order to leave comments, you need to log in
Why can't I get permission to write in sftp and how can I make it write?
Hello.
What I want to achieve:
Have a user who, when connected via sftp, he immediately got into the directory allowed to him and could do anything, but did not go beyond that directory (he did not even see the contents of those directories). I need this to work without mount and without ln
Here are the commands I do:
addgroup –-system sftpusers
nano /etc/ssh/sshd_config
#там я пишу
Subsystem sftp internal-sftp
Match Group sftpusers
ChrootDirectory %h
ForceCommand internal-sftp -u 0007
AllowTcpForwarding no
X11Forwarding no
#далее продолжаем
useradd -d /var/www/mysite.com -s /bin/false -g sftpusers user4
passwd user4
mkdir /var/www
mkdir /var/www/mysite.com
find /var/www/mysite.com -type f -exec chmod 660 {} \;
find /var/www/mysite.com -type d -exec chmod 770 {} \;
chown -R user4:sftpusers /var/www/mysite.com;
chmod 755 /var/www/mysite.com;
chown root:root /var/www/mysite.com;
systemctl restart sshd
Answer the question
In order to leave comments, you need to log in
It is necessary that the ChrootDirectory be owned by root:root and that the user cannot create anything in it.
useradd -d /var/www -s /bin/false -g sftpusers user4 The subdirectory
that the user needs must have their permissions.
chown -R user4:sftpusers /var/www/mysite.com
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question