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/03/18 05:22:29 UTC
Re: How to use system proxy for connections in Mina ssh
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