RemoteSshdConfigExtensions.cs 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. using Renci.SshNet.TestTools.OpenSSH;
  2. namespace Renci.SshNet.IntegrationTests.Common
  3. {
  4. internal static class RemoteSshdConfigExtensions
  5. {
  6. private const string DefaultAuthenticationMethods = "password publickey";
  7. public static void Reset(this RemoteSshdConfig remoteSshdConfig)
  8. {
  9. remoteSshdConfig.WithAuthenticationMethods(Users.Regular.UserName, DefaultAuthenticationMethods)
  10. .WithChallengeResponseAuthentication(false)
  11. .WithKeyboardInteractiveAuthentication(false)
  12. .PrintMotd()
  13. .WithLogLevel(LogLevel.Debug3)
  14. .ClearHostKeyFiles()
  15. .AddHostKeyFile(HostKeyFile.Rsa.FilePath)
  16. .WithHostKeyCertificate(null)
  17. .ClearSubsystems()
  18. .AddSubsystem(new Subsystem("sftp", "/usr/lib/ssh/sftp-server"))
  19. .ClearCiphers()
  20. .ClearKeyExchangeAlgorithms()
  21. .ClearHostKeyAlgorithms()
  22. .ClearPublicKeyAcceptedAlgorithms()
  23. .ClearMessageAuthenticationCodeAlgorithms()
  24. .WithUsePAM(true)
  25. .Update()
  26. .Restart();
  27. }
  28. }
  29. }