@Override public void setSSHKeyPair(SSHKeyPair keyPair) { if (keysDir == null) { throw new IllegalStateException("Setting of key pair is not allowed. " + "It can only be called during the Provisioner.createCluster cycle"); } this.sshKeyPair = keyPair; // Save the ssh key pair try { Location publicKeyFile = keysDir.append(Constants.RuntimeMonitor.PUBLIC_KEY); try (OutputStream os = publicKeyFile.getOutputStream()) { os.write(keyPair.getPublicKey().getKey().getBytes(StandardCharsets.UTF_8)); } Location privateKeyFile = keysDir.append(Constants.RuntimeMonitor.PRIVATE_KEY); try (OutputStream os = privateKeyFile.getOutputStream("600")) { os.write(keyPair.getPrivateKeySupplier().get()); } } catch (IOException e) { throw new RuntimeException("Failed to save the ssh key pair", e); } }
@Override public void setSSHKeyPair(SSHKeyPair keyPair) { if (keysDir == null) { throw new IllegalStateException("Setting of key pair is not allowed. " + "It can only be called during the Provisioner.createCluster cycle"); } this.sshKeyPair = keyPair; // Save the ssh key pair try { Location publicKeyFile = keysDir.append(Constants.RuntimeMonitor.PUBLIC_KEY); try (OutputStream os = publicKeyFile.getOutputStream()) { os.write(keyPair.getPublicKey().getKey().getBytes(StandardCharsets.UTF_8)); } Location privateKeyFile = keysDir.append(Constants.RuntimeMonitor.PRIVATE_KEY); try (OutputStream os = privateKeyFile.getOutputStream("600")) { os.write(keyPair.getPrivateKeySupplier().get()); } } catch (IOException e) { throw new RuntimeException("Failed to save the ssh key pair", e); } }
ec2.importKeyPair(new ImportKeyPairRequest(name, emrConf.getPublicKey().getKey()));
if (publicKey != null) { metadata.put("ssh-keys", publicKey.getUser() + ":" + publicKey.getKey());