You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by pratap kumar raju <pr...@gmail.com> on 2018/02/08 09:09:26 UTC

How to use system proxy for connections in Mina ssh

Hi,

I had implemented Mina ssh as for my requirement. It is working as expected
if the network is not in the proxy. If My network under proxy my server and
client not working.

 I want to know how to establish a client connection over the proxy. Can
you please help how to use system proxy for connections in Mina ssh.

Re: How to use system proxy for connections in Mina ssh

Posted by Pratap Kumar Raju <pr...@gmail.com>.
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();

		client.start();

		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,
restrictedSshPort);
		System.out.println("connected to ssh client....");

		connectFuture.await();
		try {

			ClientSession sshSession = connectFuture.getSession();

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

			sshSession.addPasswordIdentity(authToken);
			sshSession.setServerKeyVerifier(new ServerKeyVerifier() {
				@Override
				public boolean verifyServerKey(ClientSession arg0, SocketAddress arg1,
PublicKey arg2) {
					return true;
				}
			});
			sshSession.auth().verify().await();
			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

Re: How to use system proxy for connections in Mina ssh

Posted by elijah baley <e_...@outlook.com>.
I am not sure I understand what you mean by


>>  If My network under proxy my server and client not working.


What do you mean by "proxy" ? SOCKS ? Tunneling ?


>> I want to know how to establish a client connection over the proxy. Can
>> you please help how to use system proxy for connections in Mina ssh.

Is there some code that show what you have done and what you are trying to achieve ?


________________________________
From: pratap kumar raju <pr...@gmail.com>
Sent: Thursday, February 8, 2018 11:09 AM
To: mina-dev@directory.apache.org
Subject: How to use system proxy for connections in Mina ssh

Hi,

I had implemented Mina ssh as for my requirement. It is working as expected
if the network is not in the proxy. If My network under proxy my server and
client not working.

 I want to know how to establish a client connection over the proxy. Can
you please help how to use system proxy for connections in Mina ssh.