Search in sources :

Example 1 with LocalAgentFactory

use of org.apache.sshd.agent.local.LocalAgentFactory in project karaf by apache.

the class DeployMojo method setupAgent.

private void setupAgent(String user, File keyFile, SshClient client) {
    URL builtInPrivateKey = ClientMojo.class.getClassLoader().getResource("karaf.key");
    SshAgent agent = startAgent(user, builtInPrivateKey, keyFile);
    client.setAgentFactory(new LocalAgentFactory(agent));
    client.getProperties().put(SshAgent.SSH_AUTHSOCKET_ENV_NAME, "local");
}
Also used : LocalAgentFactory(org.apache.sshd.agent.local.LocalAgentFactory) SshAgent(org.apache.sshd.agent.SshAgent) URL(java.net.URL) JMXServiceURL(javax.management.remote.JMXServiceURL)

Example 2 with LocalAgentFactory

use of org.apache.sshd.agent.local.LocalAgentFactory in project karaf by apache.

the class ClientMojo method setupAgent.

private void setupAgent(String user, File keyFile, SshClient client) {
    URL builtInPrivateKey = ClientMojo.class.getClassLoader().getResource("karaf.key");
    SshAgent agent = startAgent(user, builtInPrivateKey, keyFile);
    client.setAgentFactory(new LocalAgentFactory(agent));
    client.getProperties().put(SshAgent.SSH_AUTHSOCKET_ENV_NAME, "local");
}
Also used : LocalAgentFactory(org.apache.sshd.agent.local.LocalAgentFactory) SshAgent(org.apache.sshd.agent.SshAgent) URL(java.net.URL)

Example 3 with LocalAgentFactory

use of org.apache.sshd.agent.local.LocalAgentFactory in project karaf by apache.

the class Main method setupAgent.

private static void setupAgent(String user, String keyFile, SshClient client, FilePasswordProvider passwordProvider) {
    SshAgent agent;
    URL builtInPrivateKey = Main.class.getClassLoader().getResource("karaf.key");
    agent = startAgent(user, builtInPrivateKey, keyFile, passwordProvider);
    client.setAgentFactory(new LocalAgentFactory(agent));
    client.getProperties().put(SshAgent.SSH_AUTHSOCKET_ENV_NAME, "local");
}
Also used : LocalAgentFactory(org.apache.sshd.agent.local.LocalAgentFactory) SshAgent(org.apache.sshd.agent.SshAgent) URL(java.net.URL)

Example 4 with LocalAgentFactory

use of org.apache.sshd.agent.local.LocalAgentFactory in project platformlayer by platformlayer.

the class MinaSshConnection method buildAgentConnection.

@Override
public SshConnection buildAgentConnection(KeyPair agentKeyPair) throws IOException, SshException {
    LocalAgentFactory agentFactory = new LocalAgentFactory();
    SshAgent agent = agentFactory.getAgent();
    try {
        agent.addIdentity(agentKeyPair, "default");
    } catch (IOException e) {
        throw new IllegalArgumentException("Error adding agent identity", e);
    }
    MinaSshConnection agentConnection = new MinaSshConnection(new MinaSshContext(agentFactory));
    agentConnection.setHost(this.getHost());
    agentConnection.setPort(this.getPort());
    agentConnection.setUser(this.getUser());
    agentConnection.setServerKeyVerifier(this.getServerKeyVerifier());
    agentConnection.setKeyPair(this.getKeyPair());
    agentConnection.ensureConnected();
    return agentConnection;
}
Also used : LocalAgentFactory(org.apache.sshd.agent.local.LocalAgentFactory) SshAgent(org.apache.sshd.agent.SshAgent) IOException(java.io.IOException)

Aggregations

SshAgent (org.apache.sshd.agent.SshAgent)4 LocalAgentFactory (org.apache.sshd.agent.local.LocalAgentFactory)4 URL (java.net.URL)3 IOException (java.io.IOException)1 JMXServiceURL (javax.management.remote.JMXServiceURL)1