Resolving “open failed: administratively prohibited” Error in SSH Tunneling: Cross-Platform Debugging Guide


2 views

While SSH tunneling works flawlessly on Windows via PuTTY, many developers encounter the frustrating open failed: administratively prohibited: open failed error when using:

  • MacOS terminals (native or iTerm2)
  • Cygwin environments
  • Linux subsystems

This error typically occurs due to server-side security policies or client misconfigurations:

# Server-side causes
1. AllowTcpForwarding set to "no" in sshd_config
2. PermitOpen restrictions in authorized_keys
3. Port-specific forwarding limitations

# Client-side issues
1. Improper -L/-R flag syntax
2. Conflicting local port usage
3. Permission constraints

First verify your server configuration:

ssh -v -L 8080:localhost:80 user@example.com
# Check verbose output for clues

For MacOS/Cygwin specific workarounds:

# Alternative syntax that often works
ssh -N -L 8080:127.0.0.1:80 user@example.com

# If using jump hosts
ssh -J jumpuser@jumpserver -L 8080:target:80 finaluser@targetserver

If you have admin access, modify /etc/ssh/sshd_config:

AllowTcpForwarding yes
PermitOpen any
# Or restrict to specific ports:
# PermitOpen host:port host:port

Remember to restart sshd:

sudo systemctl restart sshd
# Or for older systems:
sudo service ssh restart

Create persistent tunnel configurations:

Host mytunnel
    HostName example.com
    User tunneluser
    LocalForward 5901 localhost:5900
    ExitOnForwardFailure yes
    ServerAliveInterval 30

Then simply run:

ssh -fN mytunnel

When all else fails:

  • Try dynamic forwarding: ssh -D 1080 user@host
  • Use autossh for resilient connections
  • Consider VPN alternatives if tunneling is blocked

Remember that corporate networks often impose additional restrictions that may require administrator intervention.


While SSH tunneling generally works flawlessly on Windows via Putty, many developers encounter the frustrating open failed: administratively prohibited: open failed error when using:

  • macOS Terminal or iTerm2
  • Cygwin environments
  • Linux SSH clients

This error occurs when the SSH server actively rejects your tunnel request due to security restrictions. Common triggers include:

# Typical error message
channel 2: open failed: administratively prohibited: open failed

If you control the SSH server, modify /etc/ssh/sshd_config:

AllowTcpForwarding yes
PermitOpen any
PermitTunnel yes

Then restart SSHD:

sudo systemctl restart sshd  # For systemd systems
sudo service ssh restart     # For older init systems

When you don't have server admin access:

Method 1: Using -N Flag

ssh -N -L 8080:localhost:80 user@example.com

Method 2: Try Different Forwarding Syntax

ssh -L *:8080:localhost:80 user@example.com

Enable verbose mode to identify the exact failure point:

ssh -vvv -L 8080:localhost:80 user@example.com
  • Firewall blocking the forwarded port
  • Server has AllowAgentForwarding disabled
  • Client using deprecated SSH protocol versions

For persistent tunneling needs, consider:

autossh -M 0 -N -L 8080:localhost:80 user@example.com

Or using persistent connections:

ssh -o TCPKeepAlive=yes -o ServerAliveInterval=60 [...]