I have a Windows machine that needs to connect (programmatically) to a Linux machine. I've got a public key to that machine, but I cannot seem to use it in C# using RSACryptoServiceProvider
. I get an exception:
Invalid syntax on line 10.
on this line:
rsa.FromXmlString(File.ReadAllText(PublicKeyFile));
My public key (that I was given and generated using openSSL on a Linux machine) looks like this:
---- BEGIN SSH2 PUBLIC KEY ----
Subject: server
Comment: "A public Key"
ModBitSize: 2048
AAAAB3NzaC1kc3MAAAEBAOcQut33liU3Z9Wji6gWzUwxxrMgAki4/UZDbpNLWQW2
Wov2zMkEo/oHb2eSnAbYhBSCSlrMrWzukJboww8PGoSmcQej/W75Ag8RytwDEIjv.......
What do I need to do for my C# libraries to use this key? It was generated by OpenSSL. I've tried using puttygen's keys too but they don't work with the Microsoft libraries. I can't ask them to use keys I generate via
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.KeySize = 2048;
rsa.ToXmlString(false)
I've scoured the forums but have not found a solution. How can I use the given public key in my C# code?