Search code examples
linuxcommandportforwarding

Port forwarding command


I'm trying to do a port forwarding with ssh using this command:

ssh -L 9540:localhost:8011 user@ipdest

The port is for HTTPS traffic, I’m not getting any kind of error when I run the command, actually I get the ssh connection to the destination IP.

The problem is that when I try to connect with the browser to the URL localhost:9540 it doesn’t show anything, I’m not able to reach the HTTPS service.


Solution

  • Can you please check the sshd config file with the below command and make sure that the lines in bold are like the example?

    more  /etc/ssh/sshd_config
    

    #AllowAgentForwarding yes

    AllowTcpForwarding yes

    #GatewayPorts no

    X11Forwarding yes

    #X11DisplayOffset 10

    #X11UseLocalhost yes

    #PermitTTY yes

    PrintMotd no

    #PrintLastLog yes

    #TCPKeepAlive yes

    #PermitUserEnvironment no

    #Compression delayed

    #ClientAliveInterval 0

    #ClientAliveCountMax 3

    #UseDNS no

    #PidFile /var/run/sshd.pid

    #MaxStartups 10:30:100

    PermitTunnel yes

    #ChrootDirectory none

    #VersionAddendum none

    If not please set the lines as the example and restart the sshd service, try to connect again and test your tunnel again.