I want to create reverse connection between two machines, but these is a firewall in the middle preventing all connections, except ssh. I want to create ssh tunnel using netcat, could you please tell me how to it?
You don't need to create an SSH tunnel to do this - all you need to do is get NetCat to talk on port 22, as that is all the firewall is likely to be blocking on.
man nc should give you all the information you need.
What's up? Here's the meat and potatoes:
This is assuming that sshd is listening on the remote box, which I think I can infer from your post.
Ok! So ssh is passed
So ssh is reaching out and holding hands with sshd on the remote host (for 10 seconds, anyway), and it's sitting locally with it's hand outstretched waiting for something else to grab hold. So we
Granted the one liner above doesn't actually do anything except establish a connection and then run
Naturally, to create this connection in 'reverse', you just, you know, do it the other way 'round. Backwords, if you will. Let me know how it works!
Oh yeah, also:
Beside the original post, you wrote you don't have root access to the computers, and that there is already a daemon listening on port 22.
In case you are in the sudoers group, nothankyou's solution is the one to go with:
In case you don't, but somehow ( :O ) have access to the iptables (or similar) on the machine with SSH running already, try redirecting only the other computer ip to another local port where you will be listening with NC:
First, listen using the quoted code, or simply using NC:
Second redirect the incoming traffic to port 1234 in case of a familiar source ip address:
In the reasonably case in which you don't have both some kind of root access and access to the local firewall rules, it is possible for non-root processes to bind to “privileged” ports (<1024) on Linux,use the following line to do so:
check this question from StackOverflow for more information. It might won't solve all your problems but it seems like a good hint until you'll give us a better description of your problem.