SSH Port Forwarding not working on remote server
I am trying to SSH into a server for testing an API. I had been working on it for the past 2 weeks, and it was working fine. No issues as such.
The command I was using to ssh was:
ssh -L 8000:remoteserver.com:8000 remoteserver.com
But now all of a sudden, I can SSH into the server, but the port forwarding doesn't work.
I used to enter the server, start a Django app on port 8000 and use localhost:8000
on postman to test things.
I have tried several combinations of other port numbers, but none of them work. Postman always sends back ECONNRESET
, meanwhile curl says: recv failure connection reset by peer
.
I have been stuck at this for 5 hours. Some help would be wonderful.
My SSH Config is:
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key
# Ciphers and keying
#RekeyLimit default none
# Logging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
#HostbasedAuthentication no
#IgnoreUserKnownHosts no
#IgnoreRhosts yes
#PasswordAuthentication yes
#PermitEmptyPasswords no
#ChallengeResponseAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
GatewayPorts yes
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
AcceptEnv LANG LC_*
#Banner none
Subsystem sftp /usr/libexec/sftp-server
Not sure what changed on the server, but you might have better success with
ssh -L 8000:localhost:8000 remoteserver.com
This does the same thing, but by connecting to localhost instead of remoteserver.com on remoteserver.com, you avoid possible DNS or firewall problems.