Пример #1
0
  @BeforeClass
  public static void init() throws IOException {
    assumeTrue(SystemUtils.IS_OS_UNIX);

    s_host = System.getProperty("ssh-host");
    if (s_host == null) {
      s_host = "localhost";
      s_user = "******";
      s_password = "******";
      try {
        s_keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
      } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
      }

      s_sshd = new SSHD();
      s_sshd.setUser(s_user, s_password, s_keyPair.getPublic());
      try {
        s_sshd.start();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      s_port = s_sshd.getPort();
    } else {
      s_port = Integer.parseInt(System.getProperty("ssh-test-port", "22"));
      s_user = System.getProperty("ssh-test-user", "root");
      s_password = System.getProperty("ssh-test-password", "password");
      try {
        s_keyPair =
            _getKeyPair(
                System.getProperty("ssh-test-p12", "src/test/resources/key.p12"),
                System.getProperty("ssh-test-p12-alias", "1"),
                System.getProperty("ssh-test-p12-password", "NoSoup4U"));
      } catch (KeyStoreException e) {
        throw new RuntimeException(e);
      }
    }

    System.out.println(
        "Key fingerprint is: " + OpenSSHUtils.getKeyString(s_keyPair.getPublic(), "test"));
  }
Пример #2
0
 @AfterClass
 public static void terminate() throws Exception {
   if (s_sshd != null) {
     s_sshd.stop();
   }
 }