autossh - remote binding and closing the tunnel

1

1

I'm trying to tunnel computer a to computer b (using autossh)

I want that port 8080 in a.com will be mapped to port 8080 in b.com

from computer A:

autossh -M 0 -q -f -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R 8081:localhost:22 root@b.com

in computer B:

root@b.com:~# netstat -nal | grep 8081
tcp        0      0 127.0.0.1:8081          0.0.0.0:*               LISTEN     
tcp6       0      0 ::1:8081                :::*                    LISTEN  

and from computer B:

ssh -p 8081 root@127.0.0.1 works just fine (the tunnelling works)

the problem is 127.0.0.1:8081 I don't want it to be the local host but 0.0.0.0:8081 (like in ipv6).

Also, I would like to know how can I end the tunnel - I tried ssh ~C -KL8081 but it didn't work:

Bad local forwarding specification '8081'

(I already killed the autossh in A).

Thanks!~

Guy L

Posted 2014-02-21T20:35:04.450

Reputation: 139

Answers

1

Found the answer

1)

in server B we need to add GatewayPorts yes to the file /etc/ssh/sshd_config:

in computer a autossh -f -M 0 -N -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R *:8081:localhost:22 root@b.com

killall autossh terminates the autossh session

Guy L

Posted 2014-02-21T20:35:04.450

Reputation: 139