Reverse port forwarding[edit | edit source] and

Ssh into another pc via a VPS from a client pc behind a NAT or router where the ports are blocked. The idea is for the target pc to create a SSH tunnel to either a server or directly to the client pc. Because we don't wish to expose the client pc's ports to the world a server is used as an intermediary. From the client pc we are finally able to create a ssh session back to the target through this tunnel.

Reverse SSH from the Target PC to the middleman:

ssh -R {PortOnMiddlePC}:localhost:{PortOnTargetPC} {UserOnMiddlePC}@{IPofMiddlePC}

ssh -R 19999:localhost:22 middleman@

ssh -R remoteport:localport middleman@ forward whatever connects to the remote host:port on the middleman pc back to the localhost:port from which the ssh -R command is executed(target pc in the context of this example). If you were physically on the server you would ssh to the target pc via the tunnel created by the targetpc with ssh targetusername@localhost -p 19999

But because you're not on the middelman pc you have to pull down port 19999 from it:

ssh -L {PortOnClientPC}:localhost:{PortOnMiddlePC} {UserOnMiddlePC}@{IPofMiddlePC}

ssh -L 19999:localhost:19999 middleman@

ssh -L localport:remoteport middleman@ Forward whatever connects to the localhost:port on client pc to the localhost:port on the middleman pc.

ssh the Target PC from the Client PC in another terminal:

ssh target@localhost -p {PortForwardedFromTargetPC}

ssh targetusername@localhost -p 19999

Using ssh localhost -p 19999 instead will attempt to login as client pc user, instead of as the user on the target pc. /var/log/auth.log flagged that I attempted to login as the wrong user. In other words what we attempted to do on the server pc with ssh targetusername@localhost -p 19999 is now executed on the client pc via local port forwarding from the client pc.

Enable GateWayPorts in the sshd_config file under /etc/ssh on the target pc. The client pc doesn't need sshd_config enabled. As an additional security measure use the -x flag (ssh -x target@localhost -p 19999) if you don't wish to run a X11 session, preventing the target pc from attacking the client pc. Use (ssh -X target@localhost -p 19999) for X11 session.

udp over ssh[edit | edit source]

  2. and refs

superuser 53103[edit | edit source]

  1. links to
  2. with netcat but Brian Marshall and Zakaria have an alternative solution using socat. It eliminates the fifo file requirement. Here's how to do:
Server side: socat tcp4-listen:5353,reuseaddr,fork UDP:nameserver:53
Client side: socat -T15 udp4-recvfrom:53,reuseaddr,fork tcp:localhost:5353 
  1. ...And this is the main improvement of socat over nc. nc will do it for one single UDP port combination, which means it will work for SNMP for "some time" until the SNMP manager chooses another source port (which it is free to do for every request). Socat handles that. nc doesn't. So with nc, SNMP forwarding will work "for a little while" only.

And not at all with parallel requests. – Peter V. Mørch Apr 20 '20 ..

sshuttel ,proxychains[edit | edit source]

  2. #sshuttle

socat[edit | edit source]

  2. socat socks4 over tor
  5. and VPN client
  8. VPN with single line
  10. from

gatewayports[edit | edit source] socat alternative

make ssh tunnel publicly accessible Warning: if you set GatewayPorts to yes this will make sshd bind your forwardings to any interface - regardless of the client configuration (-R, etc.). This can become quite a security issue if the client assumes he has limited his forwardings to f.e. localhost. Therefore, setting GatewayPorts to clientspecified is usually what you want.

Here's my answer for completion:

I ended up using ssh -R ... for tunneling, and using socat on top of 
that for redirecting network traffic to
tunnel binded to
ssh -R mitm:9999:<my.ip>:8084 me@mitm
socat TCP-LISTEN:9090,fork TCP:
Other option is to do a local-only tunnel on top of that, but i
find this much slower
ssh  -L<mitm.ip.address>:9090:localhost:9999 localhost

ssh keys[edit | edit source]

create private public keys

ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "" Only a quantum mechanics type source of indeterminacy(not randomness, which doesn't exist) enables a enough entropy(nobody knows what this word means) seed. With a concentrate of energy we have high "entropy", as the energy fills the medium we have low entropy. Usually such a situation is designed(binary opposite of random) like heating the end of a metal bar, loading it with high entropy and then allowing the heat to disperse into a low state of entropy.

Your computer's random number generator isn't connected to a Geiger counter measuring radioactive decay(source of quantum indeterminacy), hence no entropy. All those garbled numbers in your private and public keys only seem garbled, they are actually an easily cracked pattern. If you do use a Geiger counter, the minix operating system on which all OS install will flag you as a high value target back to CIA headquarters. In this numberphile video, the mathematician was unable to define what randomness is because it doesn't exist. He flails around , using analogous reasoning but of course you can't solve problem you can't even define which is why for example redirects to there is no such thing as a theory of evolution because nobody knows what is the Lagrangian that maps polypeptide space into frog space. If pigs had wheels mounted on ball bearings instead of trotters, on what scale of porcine fitness would they be? is change in the heritable characteristics of biological populations over successive generations...

If Wikipedia had written: Evolution is change in the heritable characteristics of biological populations over successive generations as the Lagrangian maps the quantum entangled DNA super computed calculations from polypeptide dinosaur space into chicken space... then at least the statement would enter the domain of Popper falsifiability but not though escape Agrippian circularity.

notes[edit | edit source] allow deny static int ecdsa_generate_private_key(u_int bits, int *nid, EC_KEY **ecdsap) metasploit create reverse shell.

links[edit | edit source]

MeshNetworking main page documenting the mesh networking technology.

  1. ssh secure shell from home to work computer
  2. command descripts


Community content is available under CC-BY-SA unless otherwise noted.