Package net.schmizz.sshj.userauth.keyprovider

Examples of net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile$Factory


    };

    @Test
    public void blankingOut()
            throws IOException, GeneralSecurityException {
        FileKeyProvider dsa = new OpenSSHKeyFile();
        dsa.init(new File("src/test/resources/id_dsa"), PasswordUtils.createOneOff(correctPassphrase));
        assertEquals(KeyUtil.newDSAPrivateKey(x, p, q, g), dsa.getPrivate());

        char[] blank = new char[correctPassphrase.length];
        Arrays.fill(blank, ' ');
        assertArrayEquals(blank, correctPassphrase);
    }
View Full Code Here


    }

    @Test
    public void getters()
            throws IOException, GeneralSecurityException {
        FileKeyProvider dsa = new OpenSSHKeyFile();
        dsa.init(new File("src/test/resources/id_dsa"), onlyGivesWhenReady);
        assertEquals(dsa.getType(), KeyType.DSA);
        assertEquals(KeyUtil.newDSAPublicKey(y, p, q, g), dsa.getPublic());
        readyToProvide = true;
        assertEquals(KeyUtil.newDSAPrivateKey(x, p, q, g), dsa.getPrivate());
    }
View Full Code Here

    }

    @Test
    public void retries()
            throws IOException, GeneralSecurityException {
        FileKeyProvider dsa = new OpenSSHKeyFile();
        dsa.init(new File("src/test/resources/id_dsa"), givesOn3rdTry);
        assertEquals(KeyUtil.newDSAPrivateKey(x, p, q, g), dsa.getPrivate());
    }
View Full Code Here

    }

    @Test
    public void fromString()
            throws IOException, GeneralSecurityException {
        FileKeyProvider dsa = new OpenSSHKeyFile();
        String privateKey = readFile("src/test/resources/id_dsa");
        String publicKey = readFile("src/test/resources/id_dsa.pub");
        dsa.init(privateKey, publicKey,
                 PasswordUtils.createOneOff(correctPassphrase));
        assertEquals(dsa.getType(), KeyType.DSA);
        assertEquals(KeyUtil.newDSAPublicKey(y, p, q, g), dsa.getPublic());
        assertEquals(KeyUtil.newDSAPrivateKey(x, p, q, g), dsa.getPrivate());
    }
View Full Code Here

        Thread.sleep(2*60*1000);   // primitive, ssh will take a little while to be ready

        final SSHClient ssh = new SSHClient();
        String $HOME=System.getProperty("user.home");
        OpenSSHKeyFile k=new OpenSSHKeyFile();
        k.init(new File($HOME+"/.haruhi/o2key.pem"));
        ssh.addHostKeyVerifier(new PromiscuousVerifier());

        ssh.connect(ipAddress);
        ssh.authPublickey("ubuntu",k);
        final Session session = ssh.startSession();
View Full Code Here

        return instances.get(0).getInstances().get(0).getPublicIpAddress();
    }

    private void logIntoIp(String ipAddress) throws IOException, InterruptedException {
        final SSHClient ssh = new SSHClient();
        OpenSSHKeyFile k = new OpenSSHKeyFile();
        k.init(new File(dotHaruhi, keyPairName + ".pem"));
        ssh.addHostKeyVerifier(new PromiscuousVerifier());

        ssh.connect(ipAddress);
        try {
            ssh.authPublickey(clusterUsername, k);
View Full Code Here

      }
      ssh.connect(hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22));
      if (loginCredentials.getPassword() != null) {
         ssh.authPassword(loginCredentials.getUser(), loginCredentials.getPassword());
      } else if (loginCredentials.hasUnencryptedPrivateKey()) {
         OpenSSHKeyFile key = new OpenSSHKeyFile();
         key.init(loginCredentials.getPrivateKey(), null);
         ssh.authPublickey(loginCredentials.getUser(), key);
      } else if (agentConnector.isPresent()) {
         AgentProxy proxy = new AgentProxy(agentConnector.get());
         ssh.auth(loginCredentials.getUser(), getAuthMethods(proxy));
      }
View Full Code Here

      }
      ssh.connect(hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22));
      if (loginCredentials.getPassword() != null) {
         ssh.authPassword(loginCredentials.getUser(), loginCredentials.getPassword());
      } else if (loginCredentials.hasUnencryptedPrivateKey()) {
         OpenSSHKeyFile key = new OpenSSHKeyFile();
         key.init(loginCredentials.getPrivateKey(), null);
         ssh.authPublickey(loginCredentials.getUser(), key);
      } else if (agentConnector.isPresent()) {
         AgentProxy proxy = new AgentProxy(agentConnector.get());
         ssh.auth(loginCredentials.getUser(), getAuthMethods(proxy));
      }
View Full Code Here

            client.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT);
            client.setTimeout(timeoutInMillis);
        }
        client.connect(machine.getPublicDnsName(), machine.getSshPort());

        OpenSSHKeyFile key = new OpenSSHKeyFile();
        key.init(adminAccess.getPrivateKey(), adminAccess.getPublicKey());
        client.authPublickey(adminAccess.getUsername(), key);

        return client;
    }
View Full Code Here

      }
      ssh.connect(hostAndPort.getHostText(), hostAndPort.getPortOrDefault(22));
      if (loginCredentials.getPassword() != null) {
         ssh.authPassword(loginCredentials.getUser(), loginCredentials.getPassword());
      } else {
         OpenSSHKeyFile key = new OpenSSHKeyFile();
         key.init(loginCredentials.getPrivateKey(), null);
         ssh.authPublickey(loginCredentials.getUser(), key);
      }
      return ssh;
   }
View Full Code Here

TOP

Related Classes of net.schmizz.sshj.userauth.keyprovider.OpenSSHKeyFile$Factory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.