please help if you can! I am running a C# windows service on PC, and want to connect from the program to my EC2 server instance on AWS. The program keeps telling me it cannot connect via SSH. If I try to connect via command prompt, I can login with my PEM key and credentials. Error that I receive is:
Error connecting to EC2: Renci.SshNet.Common.SshException: openssh key type: ssh-rsa is not supported.
Here is my code snippet, I hope someone can help:
// Specify the EC2 instance details
string serverAddress = "ec2-13-244-98-241.af-south-1.compute.amazonaws.com";
string username = "henk";
string privateKeyPath = "E:\\Inovo\\CapitecEC2Uploader\\henk.pem";
// Establish the SSH connection
try
{
Log.Debug("try connecting to EC2: " );
var privateKey = new PrivateKeyFile(privateKeyPath);
var connectionInfo = new ConnectionInfo(serverAddress, username, new PrivateKeyAuthenticationMethod(username, privateKey));
using (var client = new SshClient(connectionInfo))
{
client.Connect();
Log.Debug("connected to EC2: ");
client.Disconnect();
}
}
catch (Exception ex)
{
Log.Debug("Error connecting to EC2: " + ex.ToString());
}
I tried to convert the key to *.PPK also, with no success.