Ubuntu 18, Firewall not enabled, and I have configured sshd_config to allow forwarding and gateway :
AllowTcpForwarding yes
GatewayPorts yes
If I create a tunnel listening on all ports:
ssh -f -N -L 222:0.0.0.0:22 [email protected]
This works fine if I am logged into that machine and connect using localhost:
ssh root@localhost -p 222
But when I connect to the proxying machine from another machine the connection fails:
ssh [email protected] -p 222
ssh: connect to host 192.168.0.20 port 222: Connection refused
What am I doing wrong ??
EDIT
# lsof -n -i:222
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ssh 4937 root 4u IPv6 5877871 0t0 TCP [::1]:222 (LISTEN)
ssh 4937 root 5u IPv4 5877872 0t0 TCP 127.0.0.1:222 (LISTEN)
Even if I kill the original process and create a new process and specify the IP address lsof still shows it only listening on localhost !
ssh -f -N -L 222:192.168.0.20:22 [email protected]
lsof -n -i:222
on the host where it is working? Add that to your question....-L *:222:*:22...
. The port222
will be opened on the SSH client where you issued thessh
command. This port will then be forwarded to the server you are logging into to the port that you specifiy*:22
.