Jump to content

autossh to relay server


audibleblink
 Share

Recommended Posts

Hey Yinz,

Has anyone been able to configure autossh on the NANO?

I can run the command manually on the NANO and get it to connect to my relay server. I can then ssh into the pineapple through the relay. Perfect. My current problem is that I have to ssh into the pineapple over a physical connection to start the autossh deamon.

Things I've tried: I made a script, made executable, and put it into `/etc/init.d/myautossh` and started it. It starts just fine but on reboot of the PA, it doesn't connect to my relay server. This is most likely due to my ignorance of the unix boot process.

I was able to setup autossh with the Mark V with the GUI, but honestly, I'm excited about setting this up manually. I noticed that there is still a config file in `/etc/config/autossh`. Any chance this can still be used? Is there a setting somewhere else that lets one enable autossh manually and use this config file?

________

P.S. Because communities are better when people give as well as receive information, thought I'd share my ssh config for connecting to my NANO through a relay server (when it's working):

# autossh command from the PA that allows clients to connect through NAT and firewalls
autossh -M 20000 -R 4255:localhost:22 -i ~/path/to/id_rsa  <user>@<relay_server>

# ~/.ssh/config entry that will connect from a remote client > through the relay > into the PA
 Host pinano
   Hostname localhost
   User root
   Port 4255
   IdentityFile ~/path/to/pineapples/id_rsa
   ProxyCommand ssh -W %h:%p <user>@<relay_server> -i ~/path/to/relays/id_rsa
   DynamicForward 9999 # allows one to connect the remote client web browser through a socks proxy. This allows shell and and web access with the same tunnel

The remote client can then just type `ssh pinano` and be ssh'd in to the PA as well as have a local SOCKS proxy at 9999 that one could point a browser to and access the web interface
Link to comment
Share on other sites

Awesome that you're doing it manually. AutoSSH will become a module in time. For now you're best bet is to pop the autossh start command in your /etc/rc.local and end it with an &

eg:

autossh -M 20000 -R 4255:localhost:22 -i ~/path/to/id_rsa  <user>@<relay_server> &
# Enter commands above this line
exit 0

  • Upvote 1
Link to comment
Share on other sites

Awesome that you're doing it manually. AutoSSH will become a module in time. For now you're best bet is to pop the autossh start command in your /etc/rc.local and end it with an &

eg:

autossh -M 20000 -R 4255:localhost:22 -i ~/path/to/id_rsa  <user>@<relay_server> &
# Enter commands above this line
exit 0

This, or configure it in the /etc/config/autossh file.

Best regards,

Sebkinne

Link to comment
Share on other sites

Hmm... interesting. So if there is no internet connection at the time that either init.d or rc.local fire, the autossh process starts, but tunnel never gets created.

Both methods work after I enable ICS, ssh in over the wire, and restart autossh.

Is there something similar to Debian's `/etc/network/if-up.d` on the NANO? How can I not run the command until there's a working internet connection? Custom script/cronjob?

Link to comment
Share on other sites

Alright. I resorted to cron to get this working a little more robustly.

#!/bin/bash

createTunnel() {
  /usr/bin/ssh -N -R 4255:localhost:22 <relay_user>@<relay_ip>
  if [[ $? -eq 0 ]]; then
    echo Tunnel created successfully
  else
    echo ERROR: RC was $?
  fi
}

/bin/pidof ssh
if [[ $? -ne 0 ]]; then
  createTunnel
fi

and then entered it into `crontab`

*/1 * * * * ~/autossh.sh > /var/log/tunnel.log 2>&1
Link to comment
Share on other sites

Hmm... interesting. So if there is no internet connection at the time that either init.d or rc.local fire, the autossh process starts, but tunnel never gets created.

Both methods work after I enable ICS, ssh in over the wire, and restart autossh.

Is there something similar to Debian's `/etc/network/if-up.d` on the NANO? How can I not run the command until there's a working internet connection? Custom script/cronjob?

That doesn't sound right, the whole point of AutoSSH is that it will keep trying, even if there is no internet connection...

I know people are already working on both AutoSSH and OpenVPN modules, so we'll get these issues resolved.

Glad you found a workaround for now though!

Link to comment
Share on other sites

  • 3 years later...

Hey I set up a relay server for my pineapple tetra and been sorta following this video somewhat 

I got everything thing working including the auto auth. with the pubkey, but can't seem to figure out accessing the web interface through it using the new autossh interface, can someone give me some tips plzzz

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...