Files
Wojciech Nagórski f1297dec75 Move test projects (#1212)
* Move test projects to test folder.
Move global.json to root of repo.
Update solution items in solution.

* Move test projects to test folder.
Move global.json to root of repo.
Update solution items in solution.
Update appveyor configuration/

* Attempt to have appveyor use the correct .NET SDK.

* Update .NET SDK to version 7.0.402.

* Move Data folder below Renci.SshNet.Tests.

* Make csinst less chatty.

* Move Data folder directly below test folder as it's used by multiple test projects.

* Remove CS1591 nowarn from concrete test projects as this is already defined in the Directory.Build.props that is in the test folder.

* Fix integration test after moving test projects

---------

Co-authored-by: drieseng <gert.driesen@telenet.be>
2023-10-14 22:16:11 +02:00

37 lines
1.2 KiB
C#

namespace Renci.SshNet.IntegrationTests
{
internal class SshConnectionRestorer : IDisposable
{
private SshClient _sshClient;
public SshConnectionRestorer(SshClient sshClient)
{
_sshClient = sshClient;
}
public void RestoreConnections()
{
var command = _sshClient.CreateCommand("sudo sed -i '/DenyUsers sshnet/d' /etc/ssh/sshd_config");
var output = command.Execute();
if (command.ExitStatus != 0)
{
throw new ApplicationException(
$"Unblocking user sshnet failed with exit code {command.ExitStatus}.\r\n{output}\r\n{command.Error}");
}
command = _sshClient.CreateCommand("sudo /usr/sbin/sshd.pam");
output = command.Execute();
if (command.ExitStatus != 0)
{
throw new ApplicationException(
$"Resuming ssh service failed with exit code {command.ExitStatus}.\r\n{output}\r\n{command.Error}");
}
}
public void Dispose()
{
_sshClient?.Dispose();
_sshClient = null;
}
}
}