"Not authenticated to the server." - error on executing SFTP putfile command C#

0 votes
asked Jan 17 by YahudhaJames (160 points)

I have been trying to transfer files through Rebex SFTP.
The connection of the SFTP is successful, but on execution of putfile command or GetList command, the following log is written :
"Not authenticated to the server."

What could be that I am missing.?

Applies to: Rebex SFTP
commented Jan 17 by YahudhaJames (160 points)
I have been connect to the Server using CuteFTP,  with the same credentials along with the pfx  file (as private key) and cer file (as public key).
but then the code doesnt allow me to execute the PuFile command, neither does it download by GetFile command..

1 Answer

+1 vote
answered Jan 17 by Lukas Pokorny (92,830 points)
selected Jan 18 by YahudhaJames
 
Best answer

Please make sure you call both the Connect and Login methods before calling PutFile/GetFile, and that the Login method actually succeeds. If you don't find any problem, create a communication log using Sftp object's LogWriter property and either post it here or mail it to support@rebex.net. Based on the log, we should be able to tell what is going on.

commented Jan 17 by YahudhaJames (160 points)
Hi Lukas,
As you said I checked the code, and yes the Login method was commented..
I uncommented it, and only two parameters were being passed, i.e, 'username and password'.

And on running the service, following log was written :
"Authentication was partially successful, but server requires additional authentication with: 'publickey'."

The Login constructor accepts a third parameter also, which is but a SshPrivatekey type.

Any suggestions.?
commented Jan 17 by Lukas Pokorny (92,830 points)
a) If you are trying to authenticate using a certificate, try this:
    https://www.rebex.net/sftp.net/features/authentication.aspx#x509-certificate

b) If you are trying to authenticate using a public key with a private key stored in a PFX file, initialize the SshPrivateKey this way instead:
    https://www.rebex.net/sftp.net/features/private-keys.aspx#asymmetric-algorithm-keys

Additionally, if you need to use password as well, use the Login method that accepts both password and private key.
commented Jan 17 by YahudhaJames (160 points)
I have tried authenticating using both the methods..

But the SshPrivateKey object is expecting more than one arguments..
commented Jan 17 by Lukas Pokorny (92,830 points)
SshPrivateKey has 5 constructors and two of them expect one argument: http://help.rebex.net/##RebexTotalPack.chm/Html/O_T_Rebex_Net_SshPrivateKey_ctor.htm
(Unless you use a very outdated version of Rebex SFTP)
...