for (KeyPair pair : provider.getKeys()) { CLI.LOGGER.log(FINE, "Offering {0} private key", pair.getPrivate().getAlgorithm()); session.addPublicKeyIdentity(pair); session.auth().verify(10000L); try (ClientChannel channel = session.createExecChannel(command.toString())) { channel.setIn(new NoCloseInputStream(System.in)); channel.setOut(new NoCloseOutputStream(System.out));
@Override protected ClientSessionImpl doCreateSession(IoSession ioSession) throws Exception { return new ClientSessionImpl(getClient(), ioSession); } }
@Override public void exceptionCaught(Throwable t) { signalAuthFailure(authFuture, t); super.exceptionCaught(t); }
private static AuthFuture authPassword(ClientSession s, String user, String pswd) throws IOException { s.setUsername(user); s.addPasswordIdentity(pswd); return s.auth(); }
private static AuthFuture authPublicKey(ClientSession s, String user, KeyPair pair) throws IOException { s.setUsername(user); s.addPublicKeyIdentity(pair); return s.auth(); }
@Override public void start() { ClientSession session = getClientSession(); if (!session.isAuthenticated()) { throw new IllegalStateException("Session is not authenticated"); } startHeartBeat(); }
@Override public ConnectFuture connect(String username, SocketAddress targetAddress, SocketAddress localAddress) throws IOException { return creator.connect(username, targetAddress, localAddress); }
@Override protected void receiveKexInit(Map<KexProposalOption, String> proposal, byte[] seed) throws IOException { mergeProposals(serverProposal, proposal); setServerKexData(seed); }
protected void futureDone(IoWriteFuture future) { Throwable t = future.getException(); if (t != null) { getSession().exceptionCaught(t); } }
@Override protected void preClose() { signalAuthFailure(authFuture, new SshException("Session is being closed")); super.preClose(); }
@Override protected void handleDisconnect(int code, String msg, String lang, Buffer buffer) throws Exception { signalAuthFailure(authFuture, new SshException(code, msg)); super.handleDisconnect(code, msg, lang, buffer); }
@Override public Service create(Session session) throws IOException { return new ClientUserAuthService(session); } }
@Override public ClientSession getSession() { return getClientSession(); }
@Override protected ClientSessionImpl doCreateSession(IoSession ioSession) throws Exception { return new ClientSessionImpl(getClient(), ioSession); } }
@Override public void exceptionCaught(Throwable t) { signalAuthFailure(authFuture, t); super.exceptionCaught(t); }
@Override public ConnectFuture connect(String username, String host, int port, SocketAddress localAddress) throws IOException { return creator.connect(username, host, port, localAddress); }
@Override public ConnectFuture connect(String username, SocketAddress targetAddress, SocketAddress localAddress) throws IOException { return creator.connect(username, targetAddress, localAddress); }
@Override public ConnectFuture connect(String username, String host, int port, SocketAddress localAddress) throws IOException { return creator.connect(username, host, port, localAddress); }
/** * @param hostConfig The effective {@link HostConfigEntry} to connect to - never {@code null} * @return A {@link ConnectFuture} * @throws IOException If failed to create the connection future */ default ConnectFuture connect(HostConfigEntry hostConfig) throws IOException { return connect(hostConfig, null); }
@Override public ConnectFuture connect(HostConfigEntry hostConfig) throws IOException { return creator.connect(hostConfig); }