System.exit(exitStatus);
}
protected static SshAgent startAgent(String user, String keyFile) {
try {
SshAgent local = new AgentImpl();
URL builtInPrivateKey = Main.class.getClassLoader().getResource("karaf.key");
InputStream is = builtInPrivateKey.openStream();
ObjectInputStream r = new ObjectInputStream(is);
KeyPair keyPair = (KeyPair) r.readObject();
is.close();
local.addIdentity(keyPair, user);
if (keyFile != null) {
String[] keyFiles = new String[]{ keyFile };
FileKeyPairProvider fileKeyPairProvider = new FileKeyPairProvider(keyFiles);
for (KeyPair key : fileKeyPairProvider.loadKeys()) {
local.addIdentity(key, user);
}
}
return local;
} catch (Throwable e) {
System.err.println("Error starting ssh agent for: " + e.getMessage());