SFTP Permission Denied w/ OpenFile Method
Question:
We are trying to upload a file to SFTP using private key. We are able to connect and retrieve folder listing. But when we try to upload to one of the folder on the SFTP we get the “Permission denied” error message.
The message is as below.
ChilkatLog: OpenFile: DllDate: Feb 15 2010 UnlockPrefix: **** Username: joe Component: .NET 2.0 SshVersion: SSH-1.99-OpenSSH_3.8p1 SftpVersion: 3 filename: .\Upload\myFiles\test.xml access: writeOnly createDisposition: createNew v3Flags: 0x2a Sent FXP_OPEN StatusResponse: Request: FXP_OPEN StatusCode: 3 StatusMessage: Permission denied SshLog: SFTP> Sending SSH_FXP_OPEN TRAN> CHANNEL_DATA TRAN* NumBytes: 44 TRAN< CHANNEL_DATA SFTP< Received SSH_FXP_STATUS
Answer:
The content of the LastErrorText property (as shown above) provides good information that allows me to suggest some things to try:
- I can see by the “DllDate” that the version being used is older. I would highly recommend updating to the latest version to ensure you’re getting the best information in LastErrorText. The information in LastErrorText is always being refined and improvedd as Chilkat does user-support day-to-day.
- The createDisposition passed to OpenFile in this case is “createNew”. If the file already exists, then the OpenFile will fail. It’s possible that the server will indicate the failure as a “Permission denied” error. Instead, use “createTruncate” for the createDisposition argument.
- I see that backslashes are used in the remote file path. Try using forward slashes instead.
- To fully understand the absolute file path of the destination file on the SSH/SFTP server, call RealPath to ask the server to convert a relative path to an absolute path. Maybe the SSH/SFTP user account’s home directory is something different than expected.
admin
0
Tags :