Accessing SSH When Port 22 is Blocked: Solutions and Recommendations

Bakunga BronsonBakunga Bronson
3 min read

Introduction: Secure Shell (SSH) is a vital tool for developers and accessing platforms like GitHub. However, some networks, such as those provided by Simba Net in Uganda, often block traffic to port 22, making SSH inaccessible. This article aims to provide solutions for developers and users to overcome this limitation and regain access to SSH.

Solution 1: VPN (Free and Paid)

A Virtual Private Network (VPN) is a popular solution for bypassing port restrictions. By routing traffic through a VPN server, you can circumvent port blocking and access SSH. One recommended VPN is ProtonVPN, known for its generous free tier and wide range of countries to choose from.

Pros:

  • Relatively easy setup process.

  • Allows you to access blocked sites and services.

Cons:

  • The free tier might have slower connection speeds.

  • Concerns about the security and privacy of personal information.

  • Some VPNs may cause compatibility issues with certain websites, like GitHub.

Alternative Solution:

  • Microsoft Edge VPN: If you use Microsoft Edge as your browser, it offers a built-in free VPN that can be activated. While this can help with broken websites, it's important to consider data consumption, especially with limited internet bundles.

  • Proxy: Consider using an online proxy service to access SSH and bypass port restrictions. I recommend Hide Me.

Solution 2: Changing the SSH Port on Your Server

By modifying the SSH port on your virtual machine or server, you can bypass port 22 restrictions without relying on third-party tools. Follow these steps:

  1. Connect to your VM using your preferred method (VPN, for example).

  2. Edit the "/etc/ssh/sshd_config" file using a text editor like Vim (commonly pre-installed in Linux distributions).

  3. Uncomment the line "#Port 22" and change "22" to an available port of your choice.

  4. Ensure that the new port is open in the firewall settings of your server.

  5. Restart or reload the sshd service using the command "sudo service sshd restart" or "sudo service sshd reload".

Note: Always test the new SSH connection in a separate terminal to ensure everything is working as intended.

Solution 3: Tailscale VPN

Tailscale VPN is a user-friendly solution that leverages the Wireguard protocol. It simplifies device connectivity without requiring port openings, as it utilizes network hole punching. This eliminates the need for special permissions.

Pros:

  • Easy setup process.

  • Allows unlimited connections for a single user.

  • Offers additional security options, such as running an exit node on one of your machines.

Cons:

  • May disrupt certain services like WhatsApp web and some HTTPS connections, leading to logouts.

Alternative Solutions:

  • Tailscale has an experimental HTTPS feature option that you can use to fix the issue with WhatsApp and HTTP connections.

Conclusion

When faced with port 22 blocking, developers and users have several options to regain access to SSH. VPNs, changing the SSH port, and Tailscale VPN all provide viable solutions. Consider the specific requirements and limitations of each option to determine the best fit for your needs. Remember to prioritize security and privacy while exploring alternative methods.

0
Subscribe to my newsletter

Read articles from Bakunga Bronson directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Bakunga Bronson
Bakunga Bronson