I have to forward my data from one port to another port by secure way(ssh packet). This should happen from local machine to server machine via port. so I used ssh tunnel to achieve this.
The logic behind is send the command to create SSH tunnel from client to server, create socket and then try connect the same. so when i use below command through command prompt to create ssh tunnel and then everything fine if i run same command in java code(which i pasted below)then it's throwing below exception
SSH Socket creation failed java.net.Connec tException: Connection refused: connect
SSH Socket creation failed java.net.Connec tException: Connection refused: connect
SSH Socket creation failed java.net.Connec tException: Connection refused: connect
SSH Socket creation failed java.net.Connec tException: Connection refused: connect
SSH Socket creation failed java.net.Connec tException: Connection refused: connect
SSH Tunneling failed - falling back to insecure connection*****
Java code:
could any one please help me out?
Thanks
The logic behind is send the command to create SSH tunnel from client to server, create socket and then try connect the same. so when i use below command through command prompt to create ssh tunnel and then everything fine if i run same command in java code(which i pasted below)then it's throwing below exception
SSH Socket creation failed java.net.Connec tException: Connection refused: connect
SSH Socket creation failed java.net.Connec tException: Connection refused: connect
SSH Socket creation failed java.net.Connec tException: Connection refused: connect
SSH Socket creation failed java.net.Connec tException: Connection refused: connect
SSH Socket creation failed java.net.Connec tException: Connection refused: connect
SSH Tunneling failed - falling back to insecure connection*****
Java code:
Code:
String sshCommand = "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q -N -T -L"+ portNo +":" + address + ":" + port + " svc_pos_client@" + address + " &" ;
try
{
System.out.println( "createSSHTunnel() - Creating ssh tunnel with " + sshCommand);
//Runtime.getRuntime().exec(sshCommand);
Process process=Runtime.getRuntime().exec(sshCommand);
}
Thanks
Comment