question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SFTP Connection fails with "permission denied" but I can connect using the sftp cli

See original GitHub issue

I am trying to connect to a client’s SFTP server using a username and password that they provided. When connecting using SSH.NET I get the error Renci.SshNet.Common.SftpPermissionDeniedException: permission denied thrown, but I can connect using the same username and password using the sftp cli binary and other sftp tools.

Any idea what to change on my end, or how to debug what is different between the two methods of access?

Thanks

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
devdotatbcommented, Nov 2, 2022

image

I also have same error ( key already changed to OpenSSH )

0reactions
maxfurmancommented, Nov 2, 2022

I cloned the repo locally, built in debug mode, and dumped out the logs. Here’s what I see:

Initiating connection to 'XXXXXX'.
Server version '2.0' on 'XXXXX'.
[] Received message 'KeyExchangeInitMessage' from server: 'SSH_MSG_KEXINIT'.
[] Sending message 'KeyExchangeInitMessage' to server: 'SSH_MSG_KEXINIT'.
[] Sending message 'KeyExchangeEcdhInitMessage' to server: 'SSH_MSG_KEX_ECDH_INIT'.
[] Received message 'KeyExchangeEcdhReplyMessage' from server: 'SSH_MSG_KEX_ECDH_REPLY'.
[] Sending message 'NewKeysMessage' to server: 'SSH_MSG_NEWKEYS'.
[] Received message 'NewKeysMessage' from server: 'SSH_MSG_NEWKEYS'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Creating server cipher (Name:aes256-ctr,Key:<long key removed>,IV:<long IV removed>)
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Sending message 'ServiceRequestMessage' to server: 'SSH_MSG_SERVICE_REQUEST'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'ServiceAcceptMessage' from server: 'SSH_MSG_SERVICE_ACCEPT'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'BannerMessage' from server: 'SSH_MSG_USERAUTH_BANNER'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Sending message 'RequestMessageNone' to server: 'SSH_MSG_USERAUTH_REQUEST'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'FailureMessage' from server: 'SSH_MSG_USERAUTH_FAILURE'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Sending message 'RequestMessagePassword' to server: 'SSH_MSG_USERAUTH_REQUEST'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'SuccessMessage' from server: 'SSH_MSG_USERAUTH_SUCCESS'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Sending message 'ChannelOpenMessage' to server: 'SSH_MSG_CHANNEL_OPEN'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'ChannelOpenConfirmationMessage' from server: 'SSH_MSG_CHANNEL_OPEN_CONFIRMATION : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Sending message 'ChannelRequestMessage' to server: 'SSH_MSG_CHANNEL_REQUEST : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'ChannelWindowAdjustMessage' from server: 'SSH_MSG_CHANNEL_WINDOW_ADJUST : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'ChannelSuccessMessage' from server: 'SSH_MSG_CHANNEL_SUCCESS : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Sending message 'ChannelDataMessage' to server: 'SSH_MSG_CHANNEL_DATA : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'ChannelDataMessage' from server: 'SSH_MSG_CHANNEL_DATA : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Sending message 'ChannelDataMessage' to server: 'SSH_MSG_CHANNEL_DATA : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'ChannelDataMessage' from server: 'SSH_MSG_CHANNEL_DATA : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Sending message 'ChannelDataMessage' to server: 'SSH_MSG_CHANNEL_DATA : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'ChannelDataMessage' from server: 'SSH_MSG_CHANNEL_DATA : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Sending message 'ChannelDataMessage' to server: 'SSH_MSG_CHANNEL_DATA : #0'.
[C106C1B8B8183B845214200E48F41B8E43976AC3B486AE84E71B6AD1348FE878] Received message 'ChannelDataMessage' from server: 'SSH_MSG_CHANNEL_DATA : #0'.
10:58:34 Program FATAL Error: Renci.SshNet.Common.SftpPermissionDeniedException: permission denied

It appears to successfully create the session and exchange data. I can’t figure out why these requests are denied and requests with the same username and password from the same server using the sftp builtin are permitted.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot SFTP Permission Denied: A Detailed Guide ...
To solve the SFTP permission denied error, you'll need to verify that the user account you are using to SFTP has the proper...
Read more >
'Permission Denied' Error when getting a file via SFTP
"Permission denied" is a standard message meaning that your remote user ID doesn't have permission to access the file in question.
Read more >
Why does SFTP return "permission denied" even when ...
I want to implement an FTP over two Linux(Ubuntu 20.04) munchies in order to ... SFTP would utilize password authentication (and not SSH) ......
Read more >
SFTP error #3 permission denied- Quick Resolution!!
The SFTP error #3 permission denied occurs due to incorrect permissions. We resolve it by correcting permissions and disabling transfer to ...
Read more >
SFTP Access denied problem - Microsoft Q&A
I have installed SSH Services Then I tried to connect to the SFTP, i got this error : Status: Using username "sftp". Status:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found