Re: is WeOnlyDo.Security.Cwwryptography.KeyManager - WeOnlyDo Discussion board

Re: is WeOnlyDo.Security.Cwwryptography.KeyManager (General questions)

by wodSupport, Monday, April 10, 2006, 22:42 (6805 days ago) @ lily

Well, I tried this. This is not easy, we have to figure out way to make things easier. Until we sort it out, we need small help of wodSFTP.NET but only once, and you don't need it in your application anymore.

Here's what you need to do:

1. Generate key. For example, RSA, like this:[code]System.Security.Cryptography.RSACryptoServiceProvider rsa = new System.Security.Cryptography.RSACryptoServiceProvider();[/code]By default, when you initialize RSACryptoServiceProvider it generates new key so nothing more needs to be done here. I will just use it's output from rsa.ToXmlString function (too long to paste here). You could also save output of rsa.ToXmlString somewhere since that is your key you will reuse later on!!!

2. Get its public key out in OpenSSH format. This is only tricky part - you must upload this public key to the server. Since wodFtpDLX at this point can't help you with this, you can use wodSFTP.NET's wodKeyManager, like this:[code]WeOnlyDo.Security.Cryptography.KeyManager km = new WeOnlyDo.Security.Cryptography.KeyManager();
km.FromXmlString(rsa.ToXmlString());
Console.Write(km.PublicKeyOpenSSH(WeOnlyDo.Security.Cryptography.SSHKeyTypes.RSAKey));[/code]YOU NEED TO DO THIS ONLY ONCE, so you don't need wodKeyManager in the future. You must paste this public key dumped on the screen to appropriate place on your server (usually ~/.ssh/authorized_keys2 file). It's same with wodSFTP.NET, so wodFtpDLX.NET isn't any more complex than the other one (or any other client, for that sake).

3. You generated the key, you pasted it's public key part - now use it with wodFtpDLX.NET:[code]System.Security.Cryptography.RSACryptoServiceProvider rsa = new System.Security.Cryptography.RSACryptoServiceProvider();
rsa.FromXmlString( ...xml string from step 1... );
Ftp1.PrivateKey = rsa;
Ftp1.Authentication = Authentications.PublicKey;[/code]
That's it. Hope it helped!

Kreso


Complete thread: