Reputation: 11
I am trying to connect to a SFTP server via socks5 proxy server from a standalone sftpclient, I am doing that using maverick-all library. My code works fine. Below is the code snippet :
private SshClient getSSHClient() throws Exception {
SshClient ssh = null;
SshClient forwardedConnection = null;
/**
* Create an SshConnector instance
*/
SshConnector con = SshConnector.getInstance();
Ssh2Context context = (Ssh2Context) con.getContext(SshConnector.SSH2);
setupContext(context);
context.setHostKeyVerification(new ConsoleKnownHostsKeyVerification());
SocketTransport t = new SocketTransport(hostname, port);
t.setTcpNoDelay(true);
//System.out.println("t.isConnected() ->" + t.isConnected());
ssh = con.connect(t, username, true);
PasswordAuthentication pwd = new PasswordAuthentication();
pwd.setPassword(password);
ssh.authenticate(pwd);
if (ssh.isAuthenticated()) {
System.out.println("authenticated");
// Connect via socks5 proxy
SshTransport spt = SocksProxyTransport.connectViaSocks5Proxy(hostname, port, proxyServerHost, proxyServerPort, proxyServerUsername,proxyServerPassword);
forwardedConnection = con.connect(spt, username);
PasswordAuthentication pwd2 = new PasswordAuthentication();
pwd2.setPassword(password);
forwardedConnection.authenticate(pwd2);
}
return forwardedConnection;
}
I now want to do it without using proxy authentication i.e without using proxy username and password as the proxy server (CCproxy) allows such configuration. I looked into the library code it is possible if we specify the method as '0'. Code can be found in github, below is the URL
connectViaSocks5Proxy method.
line 204.
So is there any way to specify the authentication method ?
Upvotes: 1
Views: 1646