Cannot access SSH key file in local folder path? - WeOnlyDo Discussion board

Cannot access SSH key file in local folder path? (wodFtpDLX / wodFtpDLX.NET)

by Kat, Tuesday, April 25, 2017, 23:04 (2769 days ago)

Hi I am able to access a file through a shared folder but not when I place it in my local C drive. When I'm connecting through SFTP/SSH it throws an error saying 'Cannot load key from file'. This error is thrown if I try to access it on my local C drive.

If I put the same file in a shared folder, I can connect with no issues.

Cannot access SSH key file in local folder path?

by Jasmine, Tuesday, April 25, 2017, 23:04 (2769 days ago) @ Kat

Hi Kat,

can you give us some sample code? What component exactly are you using, ActiveX or .NET?

Jasmine.

Cannot access SSH key file in local folder path?

by Kat, Tuesday, April 25, 2017, 23:16 (2769 days ago) @ Jasmine

WeOnlyDo.Security.Cryptography.KeyManager keyManager = new WeOnlyDo.Security.Cryptography.KeyManager();
keyManager.Load("\\Computer\Folder\PrivateKey.pem", keyPassword); (works)
keyManager.Load("C:\Folder\PrivateKey.pem", keyPassword); (doesn't work)

//Set authentication to public key type.
wodDlx.Authentication = WeOnlyDo.Client.Authentications.PublicKey;

//Connect private key from wodKeyManager.NET to wodSFTP.NET.
wodDlx.Blocking = true; //Use synchronous connections
wodDlx.Login = login;
wodDlx.Hostname = hostAddress;
wodDlx.Protocol = WeOnlyDo.Client.Protocols.SFTP;
wodDlx.LicenseKey = licenseKey;
wodDlxPort = port;
wodDlx.PrivateKey = keyManager.ToXmlString(WeOnlyDo.Security.Cryptography.SSHKeyTypes.RSAKey, true);
wodDlx.Connect();

Cannot access SSH key file in local folder path?

by Jasmine, Tuesday, April 25, 2017, 23:18 (2769 days ago) @ Kat

Hi Kat,

don't you have to use double-backslash for folders? Or use

keyManager.Load(@"C:\Folder\PrivateKey.pem", keyPassword);

Do you have read permissions in C \ Folder to access the privatekey pem file?

Jasmine.

Cannot access SSH key file in local folder path?

by Kat, Tuesday, April 25, 2017, 23:21 (2769 days ago) @ Jasmine

Yes, I used double back slashes in my actual code and not the sample I posted.
I just checked permissions for both folder and file. I am still receiving the message:
Failed to import key from file.

Cannot access SSH key file in local folder path?

by Jasmine, Tuesday, April 25, 2017, 23:23 (2769 days ago) @ Kat

Hi Kat,

are you absolutely sure it's same file as on shared folder? Accessing local files is basic thing - we test it like that all the time, so it must work. Something else is involved here I'm sure.

Is your app desktop app, or running as a service?

Jasmine.

Cannot access SSH key file in local folder path?

by Kat, Tuesday, April 25, 2017, 23:33 (2769 days ago) @ Jasmine

Yeah, I didn't think local file would be an issue either. I just copied the same file from the shared folder to my local desktop. It's still throwing the error.

I'm using WeOnlyDo through a wrapper DLL. It seems to run fine in Visual Studio. I can't figure out what's wrong.. Maybe when I run it through my wrapper DLL it's utilizing another user's permissions. Hmmm.

Cannot access SSH key file in local folder path?

by Jasmine, Wednesday, April 26, 2017, 07:31 (2768 days ago) @ Kat

Are you able to open this file by yourself, and dump it to screen, just for test? Without keymanager?

Jasmine.