Can’t rename file through SFTP even though user has permissions
I have two computers both running Windows 10.
Computer A is running an ssh server, and computer B tries to connect through sftp.
I have the sshd_config set as follows:
Subsystem sftp sftp-server.exe AllowUsers test ForceCommand internal-sftp ChrootDirectory "E:MyData"
User test
doesn’t belong to any group.
Inside E:MyData
there is a file named test.txt
, and user test
has permissions to read, write and modify it on computer A.
Connecting through sftp works fine, and I can read the file properly. But when I try to rename or delete it I get an error saying I don’t have enough permissions:
> sftp test@myip > rename test.txt new.txt Couldn't rename file "/test.txt" to "/new.txt": Permission denied
What am I missing?
Answer
The “permissions to read, write and modify” do not give you permissions to rename nor delete.
The renaming and deleting are considered operations with a parent directory, not with the file. So you need permissions to modify the parent directory. That’s true both on Windows and *nix. It’s not really SFTP question.