Skip to content

SFTP client to Server communication via SOCKS5 server exception #12

@amolai

Description

@amolai

I am trying to connect to a SFTP server via SOCK5 proxy from a custom SFTP client( Java) using the maverick library. Works fine.

But when I configure the proxy server to use no authentication, I get the following error.

java.io.IOException: Invalid response from SOCKS5 server (72) localhost:1080

The socks5 proxy server used is CCproxy.

This is my code.

`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);
		//SshTransport spt = HttpProxyTransport.connectViaProxy(hostname, port, proxyServerHost, proxyServerPort, proxyServerUsername, proxyServerPassword, "Maverick");
		forwardedConnection = con.connect(spt, username);
		PasswordAuthentication pwd2 = new PasswordAuthentication();
		pwd2.setPassword(password);
		forwardedConnection.authenticate(pwd2);
	}
	return forwardedConnection;
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions