You are not logged in.
Yesterday I had time to slack around so I wanted to find out a little bit more about ssh key methods, since by now I relied on the default user/pass login. My goal is to make my laptop to request for a tunnel to my home server machine (which uses port forwarding) everytime it gets power up. The point is that I can see and track everytime the laptop is online that way and get access to it. So far I did all this and I'll explain how, since it will be needed to figure out my problem. I've made a key pair, placed them where they should be, made an autossh "daemon" with systemd:
$ sudo vim /usr/lib/systemd/system/autossh.service
---------------------------------------------------------------------
[Unit]
Description=AutoSSH service for port 20000
After=network.target
[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -NR \*:20000:localhost:22 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" smirky@smirky.net -i /home/smirky/.ssh/id_rsa
[Install]
WantedBy=multi-user.targetFirstly I've tried without these options and the ExecStart looked like that
autossh -M 0 -NL 20000:localhost:22 -o TCPKeepAlive=yes smirky@smirky.netLater I figured out that I needed -NR, not -NL, since it was doing the opposite of what I needed. Anyway, everything works ok except one thing. Here's the situation which I want to happen and which actually happens:
What I expected:
1. Laptop gets powered on.
2. If there's a nearby wi-fi or a cable is plugged, the "daemon" makes a tunnel and keeps it alive.
3. The connection is dropped by bad signal or switched to another SSID.
4. The "daemon" restarts to make a new tunnel.
What really happens:
1. same
2. same
3. same
4. The "daemon" doesnt really do anything and a new tunnel isn't made.
5. On my home server:
$ sudo watch 'netstat -tnp |grep ssh'I see that a ssh CLOSE_WAIT entry is spawning every few seconds and not getting cleaned. I managed to wait a little bit to see if it gets cleared but no. If I connect my laptop to the same SSID (let's say the same IP) it gets cleaned and the problem is resolved. But if I connect to another SSID (or just another IP), my server tries to find the old tunnel and spams the watch and also a new tunnel with the new IP isn't made. If I use:
$ systemctl restart autosshby hand, it gets connected again but the problem with the watch would still be at hand.
I found out that these options that I give to autossh are only for the local PC, no options for the server, so I have to figure out a way to fix it on the server side.
Last edited by smirky (2014-06-19 10:01:48)
Personal spot :: https://www.smirky.net/ :: Try not to get lost!
Offline
Perhaps you also need to look at:
ConnectionAttempts
Specifies the number of tries (one per second) to make before exiting. The argument must be
an integer. This may be useful in scripts if the connection sometimes fails. The default is
1.
ConnectTimeout
Specifies the timeout (in seconds) used when connecting to the SSH server, instead of using
the default system TCP timeout. This value is used only when the target is down or really
unreachable, not when it refuses the connection.
and
AUTOSSH_POLL
Specifies the connection poll time in seconds; default is 600 seconds. If the poll time is less than twice the network timeouts (default 15 seconds) the network timeouts will be adjusted downward to 1/2 the poll time.
My guess there is a large timeout somewhere.
fs/super.c : "Self-destruct in 5 seconds. Have a nice day...\n",
Offline
What does 'systemctl status autossh' say?
It is most likely a host key verification issue. Try adding User=smirky to the [Service] block.
Offline