0

I new in programming I am trying to execute some Linux command from c# dotnet via SSH

While searching on the internet I found following code to connect to Linux via ssh

SshClient cSSH = new SshClient("192.168.10.144", 22, "root", "pacaritambo");
cSSH.Connect();
SshCommand x = cSSH.RunCommand("start");
cSSH.Disconnect();
cSSH.Dispose();

but in my code getting an error cSSH does not contain a definition for Connect also cSSH does not contain a definition for RunCommand

also, I have installed NuGet package Install-Package SSH.NET -Version 2016.1.0 for SshClient then also does not work

I also studied and used the following link C# send a simple SSH command

How i can establish connection ssh from c#

Viacheslav
  • 120
  • 2
  • 11
crop need
  • 1
  • 1
  • 2

1 Answers1

0

Assuming you want to send from linux to linux you can execute bash command using this extension method: https://loune.net/2017/06/running-shell-bash-commands-in-net-core/

Command would look like this: sshpass -p password ssh ..@.. command Here are details: https://www.cyberciti.biz/tips/linux-running-commands-on-a-remote-host.html