SSH Port Forwarding Last Updated : 31 Oct, 2019 Comments Improve Suggest changes Like Article Like Report SSH Port forwarding is a method used for securing TCP/IP connections. The TCP/IP packets can be tunneled through a SSH link making the data obscure thus protecting the link from attacks. SSH Port forwarding can be also seen as a form of Virtual Private Network(VPN). Types of Port Forwarding: There are 2 main types of port forwarding: Local Port Forwarding, and Remote Port Forwarding. These are explained as following below. Local Port Forwarding: Suppose you are on a local network that restricts access to a site, let us suppose example.com. To work around this we could create a tunnel through a server that is not on our network and thus has access to example.com. The command we would use is: ssh -L 9090:example.com:80 [email protected] The -L flag here tells that local port forwarding is being used. So, what the above command does is it forwards the data on local port 9090 to the server which has access to example.com through a secure SSH connection. Note here that admin is a user on the server. Now visit example.com on your browser. A second scenario would be a situation in which you want to access a service on the server which is open only on localhost for security reasons. You would use the following command: ssh -L 9090:localhost:3306 [email protected] Make a note here that localhost in the command is from the perspective of the server. The server is running a MySQl service on port 3306 and it allows only local connections. Remote Port Forwarding: The command for remote forwarding is ssh -R 9090:example.com:80 [email protected] -R flag specifies that requests on remote server port(9090) should be forwarded to example.com which is on the local network at port 80. Now if we make a request to the server on port 9090 you would get a reply from example.com. Comment More infoAdvertise with us Next Article SSH Port Forwarding A ArpitPathak1 Follow Improve Article Tags : Technical Scripter Computer Networks Technical Scripter 2019 Network-security Similar Reads What is Packet Forwarding? The process of packet forwarding simply implies the forwarding of incoming packets to their intended destination. Internet is made up of generally two terms- Interconnection and Network. So, it is a connection to a large collection of networks. A packet that is to be forwarded may be associated with 3 min read Port Forwarding on Router and Why do we need It Router port forwarding is used to allow the remote computers to connect to a specific service or computer on a Local Area Network. Now the question is why do we need it. And we will discuss all of these things one by one. Use Cases : Suppose you are at the office and want to connect to your computer 4 min read What is Ports in Networking? Whenever any application in one computer sends data to another application of a different computer then it sends using IP Address and MAC Address but how does our computer know that this data is for a specific application and this data is sent by any specific application? There comes the concept of 4 min read Difference Between SSH Local and Remote Port Forwarding SSH stands for "Secure Shell" or "Secure Socket Shell". It is a cryptographic network protocol that allows two computers to communicate and share the data over on insecure network such as the Internet. SSH protocols protect the network from various attacks. Local Port ForwardingLocal Port Forwarding 6 min read What is a Designated Port? The switch with the best path to the root switch is set to forwarding. That switch is referred to as the designated switch, and its port is referred to as the designated port. A designated port is a port that can have the lowest path cost on a Local Area Network(LAN) segment. Each segment has a port 3 min read Like