mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pratap Kumar Raju <pratap.raju1...@gmail.com>
Subject Re: How to use system proxy for connections in Mina ssh
Date Sun, 18 Mar 2018 05:22:29 GMT
Hi Baley,
Thanks for the quick response. The following are the inline comments.
-- The PROXY I am referring here is the network communication establishment
from Client to the server.

The following sample snap code I was used to establishing the client
connection to the server 

	SshClient client = SshClient.setUpDefaultClient();


		String host = new URI(this.getApiEndpoint()).getHost();
		// client.setClientProxyConnector(proxyConnector);

		// Proxy setup tried

		/*System.setProperty("java.net.useSystemProxies", "true");
		 System.setProperty("socksProxyHost", "<ip address>");
		 System.setProperty("socksProxyPort", "<port>");
		System.getProperties().put( "socksProxyHost", "<IP Address?" );
		System.getProperties().put( "socksProxyPort", "<port>" );
		//System.setProperty("java.net.useSystemProxies", "true");
		ConnectFuture connectFuture = client.connect(username, host,
		System.out.println("connected to ssh client....");

		try {

			ClientSession sshSession = connectFuture.getSession();

			if (!connectFuture.isConnected())
				throw new ConnectError("Ssh Connection not available yet");

			sshSession.setServerKeyVerifier(new ServerKeyVerifier() {
				public boolean verifyServerKey(ClientSession arg0, SocketAddress arg1,
PublicKey arg2) {
					return true;
			if (!sshSession.isAuthenticated())
				throw new ConnectError("SSH Client not Authenticated yet.");

			SshdSocketAddress local = new SshdSocketAddress("", randomLocalPort);
			SshdSocketAddress remote = new SshdSocketAddress("<local ip>", <server
response port>);
			sshSession.startLocalPortForwarding(local, remote);

I am expecting that, to connect to Mina SSH server if client network is not
under acceptable range(under a proxy)?

Sent from: http://apache-mina.10907.n7.nabble.com/Apache-MINA-Developer-Forum-f6809.html

View raw message