For anyone wondering, this is indeed possible! You just need to add some global request handlers and channel factories to the client as follows -
List<RequestHandler<ConnectionService>> globalRequestHandlers = new ArrayList<>(ClientBuilder.DEFAULT_GLOBAL_REQUEST_HANDLERS); globalRequestHandlers.add(TcpipForwardHandler.INSTANCE); globalRequestHandlers.add(CancelTcpipForwardHandler.INSTANCE); client.setGlobalRequestHandlers(globalRequestHandlers); List<ChannelFactory> channelFactories = new ArrayList<>(ClientBuilder.DEFAULT_CHANNEL_FACTORIES); channelFactories.add(DirectTcpipFactory.INSTANCE); client.setChannelFactories(channelFactories); // note you probably want to configure this! client.setForwardingFilter(AcceptAllForwardingFilter.INSTANCE); Then on the server you can create forwards like this - public Proxy startProxy(Session session) throws IOException { ConnectionService connectionService = session.getService(ConnectionService.class); Forwarder forwarder = connectionService.getForwarder(); SshdSocketAddress address = forwarder.startDynamicPortForwarding(new SshdSocketAddress(hostName, port)); return new Proxy(Type.SOCKS, address.toInetSocketAddress()); } On Wed, Apr 7, 2021 at 1:17 PM Jared Wiltshire <ja...@infiniteautomation.com> wrote: > Is there any way to initiate a port forward from the server? It seems like > it could be implemented by adding TcpipForwardHandler to the client? > > In particular I would like to open a SOCKS proxy port on the server. > OpenSSH supports this, although it is still initiated from the client. > > Thanks, > > Jared Wiltshire >