User Tools

Site Tools


ssh_reverse_tunneling

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
ssh_reverse_tunneling [2015/12/07 10:51] adminssh_reverse_tunneling [2015/12/07 10:53] admin
Line 3: Line 3:
 First make sure, you have passwordless auth on the systems. use ssh-copy-id for that. First make sure, you have passwordless auth on the systems. use ssh-copy-id for that.
  
-Dest | NAT | Source+====Dest | NAT | Source====
  
-on the Dest Host: ssh -f -N -R 10000:localhost:22 sourceuser@Dest +<code> 
-on the Source Host: ssh localhost -p 10000+on the Dest Host: 
  
-Problem with that solution is, that you always have to make sure that the tunnel from Dest to Source is in place. You can do that by a cronjob for example. +ssh -f -N -R 10000:localhost:22 sourceuser@Dest
-but you may prefer to use autossh!+
  
 +on the Source Host: 
 +
 +ssh localhost -p 10000
 +</code>
 +
 +Problem with that solution is, that you always have to make sure that the tunnel from Dest to Source is in place. You can do that by a cronjob for example. But you may want to prefer to use autossh!
 +
 +<code>
 autossh -f -N -M 10984 -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -R 10000:localhost:22 sourceuser@Dest autossh -f -N -M 10984 -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -R 10000:localhost:22 sourceuser@Dest
 +</code>
  
-Dest | NAT | Middle | Source+====Dest | NAT | Middle | Source====
  
 If destination isn't always on, eg your laptop at home, you may want to use a middleman host If destination isn't always on, eg your laptop at home, you may want to use a middleman host
  
-on the Dest Host: ssh -f -N -R 10000:localhost:22 middleuser@middle +<code> 
-on the Source Host: ssh middleuser@middle+on the Dest Host:  
 + 
 +ssh -f -N -R 10000:localhost:22 middleuser@middle 
 + 
 +on the Source Host:  
 + 
 +ssh middleuser@middle
 ssh -p 10000 destuser@127.0.0.1 ssh -p 10000 destuser@127.0.0.1
 +</code>
  
-you may want to put that in your /etc/rc.local if you got it to work.+you may want to put that in your /etc/rc.local, once you got it to work.
  
 +<code>
 autossh -f -N -M 10984 -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -R 10000:localhost:22 middleuser@middle & autossh -f -N -M 10984 -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -R 10000:localhost:22 middleuser@middle &
 +</code>
  
-note the & at the end, forgetting it may hang up your box at boot!+note the "&at the end, forgetting it may hang up your box at boot!
ssh_reverse_tunneling.txt · Last modified: 2015/12/19 14:59 by 127.0.0.1