I can directly access Host A ( 10.100.64.112)
from my HomePC
but cannot directly access Host B (172.88.3.31)
. To access Host B
, I need to first ssh to Host A
and then to Host B
.
To directly access Host B
, I tried to set up an SSH tunnel using local port forwarding with the below command on Host A
Host A # ssh [email protected] -L 4420:172.88.3.31:22
Now I tried to validate whether the tunnel is working or not
Host A # ssh 10.100.64.112 -p 4420
[email protected]'s password:
It works fine and it takes me to Host B
But If I access directly the tunnel from my HOmePC
, it does not work
$ ssh 10.100.64.112 -p 4122
ssh: connect to host 10.100.64.112 port 4122: Connection refused
On checking with netstat
, it shows the following
$ sudo netstat -an | grep 4420
tcp 0 0 127.0.0.1:4420 0.0.0.0:* LISTEN
tcp 0 0 ::1:4420 :::* LISTEN
Please suggest so that I connect to Host B
directly.
Are you aware that you type 4122 in the example?
You should try
The star implies that you listen on all addresses, and not localhost, which you cannot connect to from other machines.
You can also bind to a specific IP, but my guess is that * is what you want.
Martin's answer should work.
-L *:4420:172.88.3.31:22
-L 0.0.0.0:4420:172.88.3.31:22
-L [specific IP]:4420:172.88.3.31:22
Another way:
-L -g 4420:172.88.3.31:22
man ssh