SSH/SFTP RemoveFile: “Permission Denied”
If the SFTP server responds to a request to delete a file with the error “Permission Denied”, it means the SSH/SFTP user account does not have permission to delete the file. Here is a sample LastErrorText that shows the path of the remote file to be deleted, and the “Permission Denied” response from the server.
ChilkatLog: RemoveFile: DllDate: Jan 19 2012 UnlockPrefix: abcxyz Username: abcxyz Architecture: Little Endian; 64-bit Language: .NET 2.0 / x64 SshVersion: SSH-2.0-CoreFTP-0.2.3 SftpVersion: 3 filename: /something1/something2/something.dat StatusResponse: Request: FXP_REMOVE StatusCode: 3 StatusMessage: Permission denied Failed.
The LastErrorText shows the exact path of the file passed to the server. In the case above, it is an absolute path. If a relative path was passed, it would be relative to the HOME directory of the SSH/SFTP user account. The “Permission denied” response from the server indicates that the FXP_REMOVE message was properly formatted and correctly sent to the server. It was received correctly by the server, but the SSH/SFTP user account does not have permission to delete the requested file. The fix to this problem is not on the client-side (unless a mistake in the file path was made). The fix is on the server-side to give the SSH/SFTP user account permission to delete the requested file.