public static void CopyFileFromRemoteToLocal(string host, string user, string password, string localPath, string remotePath)
{
using (SftpClient client = new SftpClient(host, user, password))
{
client.KeepAliveInterval = TimeSpan.FromSeconds(60);
client.ConnectionInfo.Timeout = TimeSpan.FromMinutes(180);
client.OperationTimeout = TimeSpan.FromMinutes(180);
client.Connect();
bool connected = client.IsConnected;
// RunCommand(host, user, password, "sudo chmod 777 -R " + remotePath);
var file = File.OpenWrite(localPath);
client.DownloadFile(remotePath, file);
file.Close();
client.Disconnect();
}
}