mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-11 01:36:39 +00:00
d3641a0676
* Test integration tests * Update appveyor.yml * Update appveyor.yml * Update Dockerfile * Update appveyor.yml * test? * Test * Enable docker * Update appveyor.yml * Update appveyor.yml * Fix & Show additional information * Try to fix connection problems * Fix build * remove artifacts * Enable logging * Log Information only * Update appveyor.yml Co-authored-by: Rob Hague <rob.hague00@gmail.com> * Update appveyor.yml * Update appveyor.yml Co-authored-by: Rob Hague <rob.hague00@gmail.com> * Update appveyor.yml Co-authored-by: Rob Hague <rob.hague00@gmail.com> * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * sleep after restarting * Update RemoteSshd.cs * Fix tests * Dispose ports * Small improvements * Fix build * Small fixes * Revert not related changes * Test linux and windows * fix * test_script * Use real commands * Fixes * fix? * Add Appveyor TestLogger * Fix linux tests * Fix tests * Try to fix tests * Revert * Give time before * fix * revert * Give some time to process all messages after connect * ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound * fix netsh * trace * Update appveyor.yml * Update appveyor.yml * etl2pcapng * Update appveyor.yml ??? * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * Update appveyor.yml * come on !! * Update appveyor.yml * Fixes tests for linux * Reverts * Fix build * Update TestMethodForPlatformAttribute.cs * Update TestMethodForPlatformAttribute.cs * Update appveyor.yml * Issue #1253 * Install .NET SDK * next try * fix? * try * Finishing * Fixes * apt-get install dotnet-sdk-7.0 * Finish? * Add environment APPVEYOR_BAKE_IMAGE * Update test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_TimeoutConnectingToServer.cs Co-authored-by: Rob Hague <rob.hague00@gmail.com> * Fix review * Fix * Update appveyor.yml * Update appveyor.yml * Delete .runsettings --------- Co-authored-by: Rob Hague <rob.hague00@gmail.com> Co-authored-by: Robert Hague <rh@johnstreetcapital.com> Co-authored-by: Scott Xu <scott-xu@msn.com>
52 lines
2.0 KiB
C#
52 lines
2.0 KiB
C#
namespace Renci.SshNet.IntegrationTests
|
|
{
|
|
internal class RemoteSshd
|
|
{
|
|
private readonly IConnectionInfoFactory _connectionInfoFactory;
|
|
|
|
public RemoteSshd(IConnectionInfoFactory connectionInfoFactory)
|
|
{
|
|
_connectionInfoFactory = connectionInfoFactory;
|
|
}
|
|
|
|
public RemoteSshdConfig OpenConfig()
|
|
{
|
|
return new RemoteSshdConfig(this, _connectionInfoFactory);
|
|
}
|
|
|
|
public RemoteSshd Restart()
|
|
{
|
|
// Restart SSH daemon
|
|
using (var client = new SshClient(_connectionInfoFactory.Create()))
|
|
{
|
|
client.Connect();
|
|
|
|
// Kill all processes that start with 'sshd' and that run as root
|
|
var stopCommand = client.CreateCommand("sudo pkill -9 -U 0 sshd.pam");
|
|
var stopOutput = stopCommand.Execute();
|
|
if (stopCommand.ExitStatus != 0)
|
|
{
|
|
throw new ApplicationException($"Stopping ssh service failed with exit code {stopCommand.ExitStatus}.\r\n{stopOutput}\r\n{stopCommand.Error}");
|
|
}
|
|
|
|
var resetFailedCommand = client.CreateCommand("sudo /usr/sbin/sshd.pam");
|
|
var resetFailedOutput = resetFailedCommand.Execute();
|
|
if (resetFailedCommand.ExitStatus != 0)
|
|
{
|
|
throw new ApplicationException($"Reset failures for ssh service failed with exit code {resetFailedCommand.ExitStatus}.\r\n{resetFailedOutput}\r\n{resetFailedCommand.Error}");
|
|
}
|
|
}
|
|
|
|
// Socket fails on Linux, reporting inability early. This is the Linux behavior by design.
|
|
// https://github.com/dotnet/runtime/issues/47484#issuecomment-769239699
|
|
// At this point we have to wait until the ssh server in the container is available after reconfiguration.
|
|
if (Environment.OSVersion.Platform == PlatformID.Unix)
|
|
{
|
|
Thread.Sleep(300);
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}
|
|
}
|