Hi I want to connect to Esxi 6.0 hypervisor and upload a file.
I write code to connect with esxi:
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. Is it possible to perform this action? How should i properly authenticate to esxi?
Thanks for replays but 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.
please follow this steps VIA SCP.
Important: For information on moving virtual disk files, see Moving or copying virtual disks in a VMware environment (900).
VMware recommends that you use SCP to copy files to or from ESX hosts. The ESX host installation includes SCP as part of the SSH package.
For information on preventing performance and data management related issues on ESX, see Moving or copying a virtual machine within a VMware environment (1000936).
To copy a file from the ESX host to another server, use this syntax:
scp local_filename user@server:/path/where/file/should/go
Note: To copy files using SCP, you need to start the SSH service in the source and destination ESX hosts. To start the SSH client, run this command:
service sshd restart
All machines to which you copy files must also have SSH (which includes SCP) installed, configured, and be available on the same network.
Many Linux and Unix distributions include SSH and SCP. To download the software, see OpenSSH. For a list of Windows clients, see OpenSSH Windows.
In some situations, you may need to use SCP without a password prompt. For more information, see Adding SSH Keys to the Service Console so vmsnap Stops Prompting for a Password (1719).
If you want to use FTP, you need to enable its use in the ESX host. For more information, see Enabling FTP for ESX Server (1868).
Hi, thanks for response.
What if i want to do it from other machine exp Windows 7 using application write in C# whitout any additional settings to ESXi?
When I use scp local_filename user@server:/path/where/file/should/go it prompts for password so i try to Adding SSH Keys to the Service Console so vmsnap Stops Prompting for a Password (1719).
But I cant perform steps:
Restart the service: service sshd restart
I get "-sh: service: not found"
Create the SSH public key:
I get "-sh: ssh-keygen: not found"
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.
For troubleshooting look for documention of the embedded features of Busybox
Thanks for replays but 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.