TestHostKey.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.VisualStudio.TestTools.UnitTesting;
  6. using Renci.SshClient.Security;
  7. using Renci.SshClient.Tests.Properties;
  8. namespace Renci.SshClient.Tests.Security
  9. {
  10. [TestClass]
  11. public class TestHostKey
  12. {
  13. [TestMethod]
  14. public void Test_HostKey_SshRsa_Connection()
  15. {
  16. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  17. connectionInfo.HostKeyAlgorithms.Clear();
  18. connectionInfo.HostKeyAlgorithms.Add("ssh-rsa", typeof(CryptoPublicKeyRsa));
  19. using (var client = new SshClient(connectionInfo))
  20. {
  21. client.Connect();
  22. client.Disconnect();
  23. }
  24. }
  25. [TestMethod]
  26. public void Test_HostKey_SshDss_Connection()
  27. {
  28. var connectionInfo = new PasswordConnectionInfo(Resources.HOST, 22, Resources.USERNAME, Resources.PASSWORD);
  29. connectionInfo.HostKeyAlgorithms.Clear();
  30. connectionInfo.HostKeyAlgorithms.Add("ssh-dss", typeof(CryptoPublicKeyDss));
  31. using (var client = new SshClient(connectionInfo))
  32. {
  33. client.Connect();
  34. client.Disconnect();
  35. }
  36. }
  37. }
  38. }