Reputation: 331
I want to connect to Esxi 6.0 hypervisor and upload a file. I use SSH net from this topic.
using (var scp = new ScpClient("10.8.58.26", 22, "root", "MyPasword"))
{
scp.Connect();
}
But I am getting "No suitable authentication method found to complete authentication." exception. SSH on hypervisor is On and manually i can connect using putty or winscp. I tried this with linux and it is working. How should i properly authenticate to esxi?
Upvotes: 0
Views: 415
Reputation: 331
Futher research gives me: "ESXi does not use a full featured ssh-server like the well known openssh. It instead uses a lightweight version which is build into Busybox."
I figure it out on my own. I use winscp library instead of scp. Code looks like this:
SessionOptions sessionOptions= new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "xxx.xxx.xxx.xxx",
UserName = "root",
Password = "MyPasword",
SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
};
private void WinScp(SessionOptions sessionOptions, string sourceFilePath, string destinationFilePath)
{
using (Session session = new Session())
{
// Connect
session.Open(sessionOptions);
//// Upload files
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
TransferOperationResult transferResult;
transferResult = session.PutFiles(sourceFilePath, destinationFilePath, true, transferOptions);
//// Throw on any error
transferResult.Check();
}
}
SshHostKeyFingerprint can be find in "Customize System/View Logs" -> "View Support Information" of ESXi.
Upvotes: 1