The Wayback Machine - https://web.archive.org/web/20240924004626/https://www.geeksforgeeks.org/bypass-firewalls-using-ssh/
Open In App

Bypass Firewalls Using SSH

Last Updated : 08 Jul, 2022
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

SSH is a secure protocol that can be used to tunnel through firewalls. By using SSH, we can connect to a remote server and tunnel our traffic through the SSH connection. Firewalls are designed to protect networks from unauthorized access, but a firewall can also block legitimate traffic if not configured correctly. This can be a problem when we need to allow access to a specific application or service. One way to get around this issue is bypassing the firewall using ssh.

There are a few ways to bypass firewalls using SSH:

  • SSH Tunneling: This is the most common way to bypass firewalls. SSH tunneling creates a secure connection between two hosts over an insecure network. This connection can be used to tunnel traffic through the firewall.
  • SSH Port Forwarding: This is a less common way to bypass firewalls, but it can be useful in some cases. SSH port forwarding allows traffic to be forwarded from one port on the server to another port on the client.  This can be used to bypass firewalls that are blocking traffic on a specific port.
  • SSH SOCKS Proxy: This is another less common way to bypass firewalls. SSH SOCKS proxy allows traffic to be forwarded through the SSH connection. This can be used to bypass firewalls that are blocking traffic on a specific port.

Step  to Perform SSH Tunneling:

In order to bypass a firewall using SSH tunneling, we will need to set up an SSH server on a machine that is outside the firewall. We will then need to connect to this server using an SSH client and forward traffic from the client machine to the server machine. For example, let’s say that we want to bypass a firewall that is blocking all traffic to port 80. We could set up an SSH server on a machine that has port 80 open and then connect to this server using an SSH client. Once we are connected, we could then forward traffic from the local machine to port 80  on the server machine. This would allow us to bypass the firewall and access websites that are normally blocked.

Now we see setting up a SSH server on a machine that is outside the firewall.

Step 1: Install the SSH server software on the machine.

  • On Windows 11:
    • Navigate to Settings > Apps > Optional features and click on View features
    • Locate “OpenSSH server” feature, select it > check the checkbox, click Next, and then click Install.
  • On Windows 10:
    • Navigate to Settings > Apps > Apps & features > Optional features and click on Add a feature
    • Locate “OpenSSH server” feature, expand the feature > check the checkbox, and select Installation.

 

Step 2: Configure the SSH server to listen on port 80 and allow traffic to port 80 through the firewall.

On Windows: 

  • Navigate to Control Panel > System and Security > Windows Defender Firewall1 > Advanced Settings > Inbound Rules and add a new rule for port 80. 
  • Or execute the following PowerShell command as the Administrator
New-NetFirewallRule -Name sshd -DisplayName 
'OpenSSH SSH Server' -Enabled True -Direction
Inbound -Protocol TCP -Action Allow -LocalPort
80 -Program "C:\Windows\System32\OpenSSH\sshd.exe"

 

Step 3:  Start the SSH server

  • On Windows: Navigate to Control Panel > System and Security > Administrative Tools and open Services. Locate OpenSSH SSH  Server service and click Start the service.
  • Once the SSH server is up and running, and accessible remotely, the next step is to download an SSH client to the target machine. 

Step to Connect the SSH Server and Forward Traffic:

Step 1: Install the SSH client software on the target machine: The OpenSSH client is included in Ubuntu Linux distributions by default. There are a few free SSH clients available for the Windows platform. The best one is Putty, which is available online on their site.

Step 2: Connect to the SSH server and forward traffic from the target machine to port 80 on the server machine. After starting Putty, fill in the following configuration details :

In the “Host Name” field, type the publicly 
accessible IP of the SSH server
Navigate to Connection > SSH > Tunnels
Add a new forwarded port:
Source Port = Target Port for Reverse Tunnelling
Destination = 127.0.0.1:[Target Port]
Direction = Remote
Click Add
Click Open to Start the SSH session

 

At this point, the target port will be mapped to the target remote SSH server. This means that clients on the remote network will be able to access the target PC as if it was on the remote network. Basically, this creates a private tunnel between two remote end-points, enabling remote administration of a fire-walled machine.

Perform SSH Port Forwarding:

Assuming we have SSH access to a remote server, we can use SSH port forwarding to bypass firewalls.  For example, let’s say we want to access a website that is blocked by a firewall. We can use SSH port forwarding to tunnel traffic from the local machine to the remote server, and then from the remote server to the website.

To do this, we would first SSH into the remote server. Then, we would use the following command to forward  traffic from the local machine (port, 8080) to the remote server (port 80):

ssh -L 8080:localhost:80 user@remote.server.com

Now, we can access the website by going to http://localhost:8080 in the web browser. The traffic will be tunneled through the SSH connection, and the remote server will act as a proxy.

We can also use SSH port forwarding to tunnel traffic from the remote server to the local machine. For example, let’s say we want to access a database that is only accessible from the remote server. We can use SSH port forwarding to tunnel traffic from the remote server to the local machine (port 3306) and then connect to the database using the local machine.

To do this, we would first SSH into the remote server. Then, we would use the following command to forward traffic from the remote server (port 3306) to the local machine (port 3306):

ssh -R 3306:localhost:3306 user@remote.server.com

Now, we can connect to the database using the local machine. The traffic will be tunneled through the SSH connection, and the local machine will act as a proxy.

Perform SSH SOCKS Proxy:

Assuming we have an SSH server running on a remote machine that we can access:

Step 1: On the local machine, open a terminal and run the following command:

ssh -D 9999 -f -C -q -N username@remotemachine

Step 2: This will establish a SOCKS proxy on port 9999 of the local machine.

Step 3: To use the proxy, configure the browser or other application to use a SOCKS proxy on localhost:9999.

Step 4:  Browse the web all traffic will be tunneled through the SSH connection.



Previous Article
Next Article

Similar Reads

Most Popular Methods Used By Hackers to Bypass Firewalls
A firewall is a hardware or software-based network security device that protects a network from unauthorized access by monitoring all incoming and outgoing traffic to accept, deny, or drop traffic according to predefined security rules. In Simple words, it is a barrier between a secure network and an untrusted network. Hacker use various methods to
4 min read
How to Configure Firewalls in Windows?
A firewall is a network security device, either hardware or software-based, which monitors all incoming and outgoing traffic and based on a defined set of security rules it accepts, rejects or drops that specific traffic. Please refer to the article Introduction of Firewall in Computer Network for more details. We can configure 2 types of firewalls
3 min read
What is Bitvise SSH Client?
Bitvise SSH Client uses a tunneling method to ensure that your data stays encrypted from machine to machine. You can create tunnels up to five hops deep, which means that someone with malicious intent could only access your data if they were on the same network as you are. Whenever you log in with Bitvise SSH Client, all traffic between your comput
4 min read
How to Brute-Force SSH in Kali Linux?
The Secure Shell Protocol (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Its applications are remote login and command-line execution. SSH protocols are based on the client-server architecture, i.e the SSH client and the SSH server. This article explains the SSH Bruteforce attack. In thi
2 min read
Email Security Warning When Using SSL
Nowadays, it is always advisable to use SSL encryption for email. Secure email login attempts and mail delivery attacks can be prevented by configuring your server and mail client with an SSL. You can install an SSL on your email server with the help of the article that follows. Furthermore, keep in mind that SSL for email is user-based. Therefore,
6 min read
Using a Reverse WHOIS API to Beef Up Cybersecurity
There has been quite a buzz about domain names on the Web in recent years and you may be wondering why. Cybercrime, if you don’t already know, is all about abusing someone else’s online real estate (network, system, domain, IP address, server, etc.) to line perpetrators’ pockets. That’s the reason why one of the first steps that cybersecurity resea
4 min read
Throttling DDoS Attacks Using Discrete Logarithm
A Distributed Denial of Service attack, also known as a DDoS attack, can cripple your server and render it inoperable. For this reason alone you need to know how to protect yourself against them. DDoS attacks work by overwhelming a website with external requests, thereby slowing it down or taking it offline completely. Throttling DDoS Attacks:A DDo
7 min read
Port Scanning Techniques By Using Nmap
Nmap is a security auditing tool used in the security field to actively enumerate a target system/network. It is one of the most extensively used tools by network administrators and conversely attackers for reconnaissance (enumeration), the first step in the 5 phases of hacking. Nmap is used to actively probe the target network for active hosts(hos
5 min read
TCP Analysis using Wireshark
TCP or Transmission Control Protocol is one of the most important protocols or standards for enabling communication possible amongst devices present over a particular network. It has algorithms that solve complex errors arising in packet communications, i.e. corrupted packets, invalid packets, duplicates, etc. Since it is used with IP(Internet Prot
5 min read
MITM (Man in The Middle) - Create Virtual Access Point using Wi Hotspot Tool
In a client-server architecture, there can be one or more servers in the way, forwarding your request to the destination server in the most efficient way possible. These are known as Proxy servers. When there is an unwanted proxy in the network that intercepts and modifies the requests/responses, then this proxy is called a Man in the middle. This
4 min read
Footprinting Using Social Engineering Method
Prerequisites: How to Install Social Engineering Toolkit in Kali Linux? Social engineering is the act of manipulating people into giving up private or confidential information by appearing to be a likely insiders. For example, asking a person for help with your car and saying you know someone who can fix it if they get you keys to the vehicle. Some
4 min read
Application Level Hijacking Using Proxy Hacking
Application-level hijacking is one of the most popular ways hackers use to steal information. The attacker will modify the traffic and information being sent to a trusted application, then pretend the traffic came from a legitimate user. This type of attack is done on vulnerable web applications that do not use SSL to encrypt data. For this techniq
3 min read
How To Generate Rainbow Table Using WinRTGen?
Rainbow Tables are a large set of pre-computed hashes that are used for reversing cryptographic hash functions generally used for password cracking. It makes password cracking easy. Rainbow tables can be used to recover many types of password hashes for example MD4, MD5, SHA1, etc. In simpler terms, Rainbow Tables are lookup tables to compare passw
4 min read
How to Improve Cyber Attack Detection Using Social Media?
Cybersecurity threats are and on the rise, organizations need to be able to identify and stop breaches before they happen. While most cybersecurity teams are aware of traditional attack monitoring tactics like antivirus software and firewalls, they may not utilize social media intelligence (SMIN) in their efforts. SMIN combines tools like data anal
4 min read
How to make an ARP Spoofing attack using Scapy - Python
In this article, we are going to discuss the ARP Spoofing attack using Python programming. Before going deep into the code first let's understand some basic topics of what is ARP Spoofing and what it does. ARP Spoofing: The ARP spoofing is the technique to fool a computer or a device which accepts the ARP response packets even though the device doe
5 min read
Threat Hunting Using Yara
Threat hunting is a proactive approach to identifying and mitigating cyber threats that have already entered an organization's network. It involves actively searching for indicators of compromise (IOC) and signs of malicious activity that may not have been detected by traditional security measures such as antivirus software or firewalls. Threat hun
10 min read
Cyber Security Interview Questions
Cybersecurity is the act of protecting computer systems, networks, programs, and data from digital attacks, unauthorized access, damage, or theft. Cybersecurity is a critical aspect of modern technology, with its importance growing as digital systems become increasingly integrated into our daily lives. With threats ranging from data breaches to mal
15+ min read
How to hack android phones with Phonesploit
Understanding how to hack android phones with Phonesploit has become a topic of interest and concern. Phonesploit is a powerful tool that allows users to remotely access and control Android devices, offering capabilities ranging from retrieving sensitive information to executing commands on the target device. This tool leverages vulnerabilities in
6 min read
Cyber Security Tutorial
Cyber security, also known as information technology security, refers to the practice of protecting systems, networks, and programs from digital attacks. These cyber-attacks are usually aimed at accessing, changing, or destroying sensitive information, extorting money from users, or interrupting normal business processes. This cybersecurity tutoria
6 min read
What is Google Dorking?
Google Dorking is a technique used by hackers and security researchers to find sensitive information on websites using Google's search engine. It is also known as Google hacking or Google Dorking. Search FiltersGoogle Dorking involves using advanced search operations in Google to search for specific keywords, file types, or website parameters. Thes
4 min read
Sniffing of Login Credential or Password Capturing in Wireshark
Wireshark is a free and open-source packet analysis tool that lets you capture and analyze network traffic in real-time. It is available for Windows, macOS, and Linux operating systems. Wireshark captures network packets and displays the captured data in a human-readable format for easy analysis and troubleshooting of network issues. It can scan a
3 min read
Ethical Hacking Tutorial
This Ethical Hacking tutorial covers both basic and advanced concepts of Ethical Hacking. Whether you are a beginner or an experienced cybersecurity professional, this tutorial is the perfect resource to learn how to tackle vulnerabilities and weaknesses in systems before malicious hackers can exploit them. From understanding the hacking basics to
11 min read
What is Salami Attack?
A salami attack is a method of cybercrime that attackers or a hacker typically used to commit financial crimes. Cybercriminals steal money or resources from financial accounts on a system one at a time. This attack occurs when several minor attacks combine to create a sturdy attack. because of this sort of cybercrime, these attacks frequently go un
3 min read
Nmap Cheat Sheet
Nmap (Network Mapper) is a free and open-source network detection and security scanning utility. Many network and system administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring server or service availability. Nmap uses raw IP packets in a novel way to determine the hosts available o
4 min read
How To Extract rockyou.txt.gz File in Kali Linux?
The first thing that comes to mind when we think of brute-forcing a login with word lists is rockyou.txt. There is a lot of talk on the internet about rockyou.txt being the most popular file used by hackers and crackers to extract passwords. The interesting thing about this is that ethical hackers can use it to breach the security of any web applic
2 min read
Types of SQL Injection (SQLi)
SQL Injection is an attack that employs malicious SQL code to manipulate backend databases in order to obtain information that was not intended to be shown, The data may include sensitive corporate data, user lists, or confidential consumer details. This article contains types of SQL Injection with their examples. SQL Injections-LABS (a platform to
6 min read
Frequency-Hopping Spread Spectrum in Wireless Networks
Frequency-hopping spread spectrum is designed for robust operation in noisy environments by transmitting short packets at different frequencies across wide portions of channel bandwidth. The receiver correlates these "near" signals against each other and selects the best signal for demodulation, which typically gives better performance compared wit
3 min read
Orthogonal Frequency-Division Multiplexing (OFDM)
Orthogonal frequency-division multiplexing (OFDM) is a digital communication technique initially developed for use in cable television systems. OFDM is similar to the broadcasting technique known as frequency division multiplexing (also known as FDM), which uses a multitude of transmitters and receivers to send information on different frequencies
3 min read
What is Burp Suite?
Burp or Burp Suite is a set of tools used for penetration testing of web applications. It is developed by the company named Portswigger, which is also the alias of its founder Dafydd Stuttard. BurpSuite aims to be an all in one set of tools and its capabilities can be enhanced by installing add-ons that are called BApps. It is the most popular tool
5 min read
Information Security | Confidentiality
Confidentiality is the protection of information in the system so that an unauthorized person cannot access it. This type of protection is most important in military and government organizations that need to keep plans and capabilities secret from enemies. However, it can also be useful to businesses that need to protect their proprietary trade sec
5 min read
Article Tags :