29 lines
803 B
C#
29 lines
803 B
C#
using CliWrap;
|
|
using InnovEnergy.Lib.Utils.Net;
|
|
|
|
namespace InnovEnergy.Lib.Utils;
|
|
|
|
public class SshHost
|
|
{
|
|
private static Command Ssh { get; } = new Command("ssh");
|
|
|
|
public String HostName { get; }
|
|
public String User { get; }
|
|
public String? IdentityFile { get; }
|
|
public Command Command { get; }
|
|
|
|
public SshHost(String hostName, String? user = null, String? identityFile = null)
|
|
{
|
|
HostName = hostName;
|
|
User = user ?? "root";
|
|
IdentityFile = identityFile;
|
|
|
|
var identity = identityFile is not null
|
|
? $" -i {identityFile}"
|
|
: "";
|
|
|
|
Command = Ssh.WithArguments($"{User}@{HostName}{identity}");
|
|
}
|
|
|
|
public Task<Boolean> Ping() => HostName.Ping();
|
|
} |