Jump to content

autossh to relay server


audibleblink

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

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

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

Best regards,

Sebkinne

Solely configuring will make it start, or do I need to do something to /etc/init.d/autossh ?

Link to comment
Share on other sites

Solely configuring will make it start, or do I need to do something to /etc/init.d/autossh ?

Should work out of the box. To be sure execute "/etc/init.d/autoshh enable". After that, reboot and it would work just fine!

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

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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