CodexBloom - Programming Q&A Platform

Debian 11 - how to Set Up SSH Tunneling for Specific Ports: 'Connection Refused' guide

👀 Views: 62 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-08
ssh debian networking bash

Can someone help me understand I'm trying to set up an SSH tunnel on my Debian 11 server to forward a local port (8080) to a remote service running on a different server (192.168.1.100) on the same port (8080). I'm using the following command for the tunneling: ```bash ssh -L 8080:192.168.1.100:8080 user@remote-server.com ``` However, when I try to connect to `localhost:8080`, I get a 'Connection refused' behavior. I've checked the SSH daemon configuration on the remote server (located in `/etc/ssh/sshd_config`) and it allows port forwarding, as I have the following lines: ```bash AllowTcpForwarding yes GatewayPorts yes ``` After making any changes, I restarted the SSH service with: ```bash sudo systemctl restart sshd ``` I also verified that the remote server's firewall (using UFW) allows traffic on port 8080: ```bash sudo ufw allow 8080/tcp ``` Additionally, I can SSH into the remote server without any issues and can confirm that the service is running on port 8080 by using `curl` from the remote server: ```bash curl http://localhost:8080 ``` This command returns the expected output. However, when I try to `curl http://localhost:8080` from my local machine, it fails. I'm wondering if there are any additional configurations I might have missed or if there's a specific setting in Debian 11 that could prevent the tunnel from working as expected. Thanks for your help! This issue appeared after updating to Bash LTS.