Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
projects:ssh_reverse_tunnel [2016/06/08 19:24]
over23 [ALIVE] Reverse SSH Tunnel - persistentce cron added
projects:ssh_reverse_tunnel [2016/06/10 00:29]
over23
Line 4: Line 4:
 |**Related:​**| [[project:​single_boards|[Project Single Boards]]]| |**Related:​**| [[project:​single_boards|[Project Single Boards]]]|
 |**References:​**|[[http://​www.tunnelsup.com/​raspberry-pi-phoning-home-using-a-reverse-remote-ssh-tunnel]]| |**References:​**|[[http://​www.tunnelsup.com/​raspberry-pi-phoning-home-using-a-reverse-remote-ssh-tunnel]]|
-|**Materials:​**| dynamic IP device aka PICKA, static IP device aka RemoteHost, ssh able to connect between devices by keys|+|**Materials:​**| dynamic IP device aka PICKA, static IP device aka RemoteHost, ​[[project:​single_boards#​remove_password_to_ssh|ssh able to connect between devices by keys]]|
 |**THX to:**| thx to:  Jack Rhysider; @TunnelsUp; http://​www.tunnelsup.com/​raspberry-pi-phoning-home-using-a-reverse-remote-ssh-tunnel | |**THX to:**| thx to:  Jack Rhysider; @TunnelsUp; http://​www.tunnelsup.com/​raspberry-pi-phoning-home-using-a-reverse-remote-ssh-tunnel |
 |**License:​** | [[https://​creativecommons.org/​licenses/​by-sa/​3.0/​|CC Attribution-Share Alike 3.0 Unported]] ​ |  ​ |**License:​** | [[https://​creativecommons.org/​licenses/​by-sa/​3.0/​|CC Attribution-Share Alike 3.0 Unported]] ​ |  ​
 +{{ projects:​tunnel-of-plants-252820_960_720.jpg?​500|Taken from: https://​pixabay.com/​static/​uploads/​photo/​2014/​01/​27/​03/​28/​tunnel-of-plants-252820_960_720.jpg under CC; thx}}
 ===== Legend: ===== ===== Legend: =====
   * **Picka** = bannanaPi, raspberryPi,​ any othere device on dynamic IP   * **Picka** = bannanaPi, raspberryPi,​ any othere device on dynamic IP
Line 17: Line 17:
   * we have **RemoteHost**,​ that we can see from anywhere and Picka is able to SSH to that server   * we have **RemoteHost**,​ that we can see from anywhere and Picka is able to SSH to that server
   * we will build ssh tunnel from **Picka** to **RemoteHost**   * we will build ssh tunnel from **Picka** to **RemoteHost**
-  * RemoteHost and Picka should be able to reach each other by certificate,​ not by passwd+  * [[project:​single_boards#​remove_password_to_ssh|RemoteHost and Picka should be able to reach each other by certificate,​ not by passwd]]
  
 ==== on Picka do ==== ==== on Picka do ====
Line 26: Line 26:
  
 **explanation of parameters of tunnel:** **explanation of parameters of tunnel:**
-  ​ssh - shell command + ssh - shell command 
-  -N do not execute anything when connection successful + -N do not execute anything when connection successful 
-  -R bind port 22 on remote server [192.168.1.1] to 2222 + -R bind port 22 on remote server [192.168.1.1] to 2222 
  
 ==== so now connect to RemoteHost and ====  ==== so now connect to RemoteHost and ==== 
Line 58: Line 58:
  
 <​code>​ <​code>​
-#!/bin/bash+#​!/​bin/​bash ​-x
 createTunnel() { createTunnel() {
 ##### fill in vars ##### fill in vars
-  RemoteHost="​INSERT.IP.HERE.NOW+  RemoteHost="​IP_HERE
-  ServerUser="​NAME_FOR_REMOTE_USER"+  ServerUser="​NICK_HERE"
 ##### are wars filled? ##### are wars filled?
-  ​ + 
-  /​usr/​bin/​ssh -N -R 2222:​localhost:​22 ${ServerUser}@${RemoteHost}+  /​usr/​bin/​ssh -N -R 2222:​localhost:​22 ${ServerUser}@${RemoteHost} ​&
   if [[ $? -eq 0 ]]; then   if [[ $? -eq 0 ]]; then
     echo Tunnel to RemoteHost IP: ${RemoteHost} created successfully     echo Tunnel to RemoteHost IP: ${RemoteHost} created successfully
Line 92: Line 92:
  
  
- +==== Note for MAC users ==== 
 +* in case you have problem, that wiifi is turned off when screensaver is on 
 +* remember en1 should be replaced by your wiifi interface 
 +<​code>​ 
 +cd /​System/​Library/​PrivateFrameworks/​Apple80211.framework/​Versions/​Current/​Resources 
 +sudo ./airport en1 prefs DisconnectOnLogout=NO 
 +</​code>​
  • projects/ssh_reverse_tunnel.txt
  • Last modified: 2016/06/10 00:29
  • by over23