PORT FORWARDING AKA SSH TUNNELLING
What is it? Forward a port or map a port running on one computer to another computer. What does this mean :D
Lets understand by a simple example -
Suppose there are two computers — computer1 and computer2 and you have a server running on localhost:8000 on computer1
You are sitting on computer2 and want to access the server running on localhost:8000 on computer1. You can’t do it since it is a localhost server.
This is where port forwarding can help you.
If you have ssh access to computer1(obviously), you can forward the server running on 8000 port on computer1 to any port on computer2 and access it as localhost on computer2.
computer2 localhost:2201 is equals to computer1 localhost:8000
ssh -L 2201:localhost:8000 root@computer1
Meaning of this statement — ssh into computer1 with user root and forward the 3306 port running on localhost on computer1 to localhost:2201 on computer2
Now, if you open localhost:2201 on computer2, you will see same content as localhost:3306 on computer1
Usages
- Access a database server running on a remote server from local machine
- Debug remote server locally