connect from the ssh server to the remote computer using a local ip address
I have a remote Linux computer connecting on a local ssh server, creating a reverse ssh tunnel on port 5051. On the ssh server itself I run the following two commands, in order to give the remote computer a local IP address.
Code:
ip addr add 192.168.1.51/24 dev eth0 From a third computer on my network if I ssh on 192.168.1.51, I connect directly on the remote Linux computer. But from the ssh server if I ssh 192.168.1.51 I connect on the ssh server itself again. I don't connect on the remote computer. The only way to connect on the remote computer from the ssh server is to use ssh root@localhost -p 5051 But I don't want to do that. I want to be able to ssh 192.168.1.51 from the ssh server, and connect on the remote computer. |
This may not be the answer you are looking for but it is simple. If you create a ~/.ssh/config you can add an alias for your remote computer and no need to specify address or port.
https://www.google.com/amp/s/www.cyb...inux-unix/amp/ |
Thanks for the reply. Eventually this did it.
iptables -t nat -A OUTPUT -d 192.168.1.51 -p tcp --dport 22 -j REDIRECT --to-port 5051 |
By the way prerouting does not work for localhost which caused your intial problem and just thought of the rule you posted...
|
All times are GMT -5. The time now is 10:48 PM. |