Jump to content

autossh with digital ocean


kimkong

Recommended Posts

i'm working with the lan turtle  and I see a tutorial for  Persistent Shell Access with AutoSSH, when I have of lan turtle into a usb port in my pc, the lan turtle work fine, I can connect from my vps to the lan turtle without any problem, but when I activated the Autossh and connect the Lan turtle to  external battery for  try of connect from my vps to Lan turtle  is imposible  the connect,
I worked with this video https://www.youtube.com/watch?v=uIdvvrDrRj0
but  Into the vps  he only made a new user,
is possible what I need another configuration into my vps for can connect to the lan turtle using autossh

Link to comment
Share on other sites

  • 5 years later...

I have a problem that looks like…
The AutoSSH connection is up on the Turtle.

On the VPS, when I try: ssh root@localhost the connection is refused…

Edited by Éd_D
Link to comment
Share on other sites

I think that sshd is misconfigured on the vps:

root@vps:~# grep ^[^#] /etc/ssh/sshd_config 
Port 2222
PermitRootLogin no
ChallengeResponseAuthentication no
UsePAM yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp	/usr/lib/openssh/sftp-server
PasswordAuthentication yes
root@vps:~# 

(When commissioning, I only uncommented the Port directive, changed 22 to 2222 on this ligne and changed yes to no for the PermitRootLogin directive…)

Link to comment
Share on other sites

2 hours ago, chrizree said:

Did you use the correct port?

I tried both:

turtle@vps:~$ ssh root@localhost
ssh: connect to host localhost port 22: Connection refused
turtle@vps:~$ ssh -p 22 root@localhost
ssh: connect to host localhost port 22: Connection refused
turtle@vps:~$ ssh -p 2222 root@localhost
root@localhost's password: 
Permission denied, please try again.
root@localhost's password: 
Permission denied, please try again.
root@localhost's password: 
^C
turtle@vps:~$ 

 

Link to comment
Share on other sites

3 hours ago, chrizree said:

Was that default settings or did you change the file yourself? Why add the vps to 2222?

In fact, I have changed the ssh port (22) by a custom one (port number chosen between 49152 and 65535) for security reason.

When I copy commands and screen output on the forum, I write 2222 instead the real l number because "2222" look nice as customed ssh number…

🙂

Edited by Éd_D
Link to comment
Share on other sites

On the LAN Turtle, AutoSSH is running:

root@turtle:~# ps
[…]
28771 root       936 S    /usr/sbin/autossh -M 20000    -i /root/.ssh/id_rsa -N -T -R xxxxx:localhost:22 turtle@vps.domain.tld -p 22
[…]
root@turtle:~# 

(Debian man page about autossh [https://manpages.debian.org/bullseye/autossh/autossh.1.en.html] is not complete enough to understand all the command line arguments.)

From here, everything looks ok. No problem with the ssh connection to the VPS.

Edited by Éd_D
Link to comment
Share on other sites

With the autossh module stopped in the Turtle "text based GUI", try running the following directly from the terminal on the Turtle (change user@address to something relevant for your setup and ports as well, if not "default")
autossh -M 20000 -i /root/.ssh/id_rsa -R 2222:localhost:22 user@address -p 22 -N -T
 
If that works (it should), change the following line in /etc/turtle/modules/autossh from:
uci set autossh.@autossh[0].ssh="-i /root/.ssh/id_rsa -N -T -R "$autossh_remoteport":localhost:"$autossh_localport" "$autossh_host" -p "$autossh_port" "
 to:
uci set autossh.@autossh[0].ssh="-i /root/.ssh/id_rsa -R "$autossh_remoteport":localhost:"$autossh_localport" "$autossh_host" -p "$autossh_port" -N -T"
 
Furthermore... to get the module itself working, change the lines in the "configure" function of the autossh module from:
    autossh_host=$(uci show autossh.@autossh[0].ssh | awk '{print $7}' | sed "s/'//g")
    autossh_port=$(uci show autossh.@autossh[0].ssh | awk '{print $9}' | sed "s/'//g")
    autossh_remoteport=$(uci show autossh.@autossh[0].ssh | awk '{print $6}' | sed 's/:/ /g' | awk '{print $1}')
    autossh_localport=$(uci show autossh.@autossh[0].ssh | awk '{print $6}' | sed 's/:/ /g' | awk '{print $3}')
 to:
    autossh_host=$(uci show autossh.@autossh[0].ssh | awk '{print $5}' | sed "s/'//g")
    autossh_port=$(uci show autossh.@autossh[0].ssh | awk '{print $7}' | sed "s/'//g")
    autossh_remoteport=$(uci show autossh.@autossh[0].ssh | awk '{print $4}' | sed 's/:/ /g' | awk '{print $1}')
    autossh_localport=$(uci show autossh.@autossh[0].ssh | awk '{print $4}' | sed 's/:/ /g' | awk '{print $3}')
 
Also change the line in the "start" function of the autossh module from:
autossh_host=$(uci show autossh.@autossh[0].ssh | awk '{print $7}' | sed 's/@/ /g' | awk '{print $2}')
to:
autossh_host=$(uci show autossh.@autossh[0].ssh | awk '{print $5}' | sed 's/@/ /g' | awk '{print $2}')

Done!

  • Like 1
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.

  • Recently Browsing   0 members

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