SSH Remote Port Forwarding Empty Response - ssh

I am trying to Remote port forward from Raspberry pi in my local network using ssh on my windows pc
ssh -R 5941:localhost:8000 pi#192.168.1.191
So from the above command, I am trying to forward connections from port 5941 on Raspberry pi server (192.168.1.191) to port 8000 on my pc (localhost) which hosts a web server on port 8000
The above ssh command executes with no errors but when i try to access http://localhost:5941/ on Raspberry Pi (192.168.1.191) i get
ERR_EMPTY_RESPONSE
I have tried
Turned off firewall on my Windows PC
netstat on raspberrypi gives me
$ sudo netstat -a | grep 5941
tcp 0 0 0.0.0.0:5941 0.0.0.0:* LISTEN
tcp6 0 0 [::]:5941 [::]:* LISTEN
when i run the ssh command in verbose mode
ssh -R 5941:localhost:8000 pi#192.168.1.191 -v
I get this
debug1: Remote connections from LOCALHOST:5941 forwarded to local address localhost:8000
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions#openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: console supports the ansi parsing
debug1: client_input_global_request: rtype hostkeys-00#openssh.com want_reply 0
debug1: Remote: Forwarding listen address "localhost" overridden by server GatewayPorts
debug1: remote forward success for: listen 5941, connect localhost:8000
debug1: All remote forwarding requests processed
and when i try to access http://localhost:5941/ on Raspberry Pi (192.168.1.191) i get this on ssh console
debug1: client_input_channel_open: ctype forwarded-tcpip rchan 3 win 2097152 max 32768
debug1: client_request_forwarded_tcpip: listen localhost port 5941, originator ::1 port 58122
debug1: getsockopt TCP_NODELAY: Invalid argument
debug1: connect_next: host localhost ([::1]:8000) in progress, fd=7
debug1: channel 1: new [::1]
debug1: confirm forwarded-tcpip
debug1: channel 1: connected to localhost port 8000
debug1: channel 1: free: ::1, nchannels 2
How should I further diagnose my problem ?

The solution to this is to put 127.0.0.1 instead of localhost
ssh -R 5941:127.0.0.1:8000 pi#192.168.1.191
This forces ipv4 instead of ipv6, for some reason ssh port forwarding in windows fails to work on ipv6, I was able to work the same command with localhost on linux just fine.
I found the solution from this post here

Related

SSH times out when trying to connect

A few days ago i was rsyncing files to my server but it suddenly froze. Then i noticed that my SSH session also froze. When i tried sshing back it froze once again. Today my friend wanted me to ssh into his server so he made me a user gave it a password etc... (Note that he has succesfully ssh-ed in and sshd is running on port 22) but when i tried to connect it froze once again so i ran the command again with:
-vvv
The output is:
OpenSSH_9.1p1, OpenSSL 1.1.1q 5 Jul 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname <the ip address of the server> is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/anon/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/anon/.ssh/known_hosts2'
debug3: ssh_connect_direct: entering
debug1: Connecting to ip [ip] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: connect to address ip port 22: Connection timed out
ssh: connect to host ip port 22: Connection timed out
That is the info i was able to gather but here is some general system info:
Os: arch (freshly updated)
I haven't tried much apart from updating my system since i am not an expert at SSH.

Getting connection time out while doing ssh on linux server from oracle cloud shell . It shows FIPS mode initialized and then it gets timed out again

Getting connection time out while doing ssh on linux server from oracle cloud shell . It shows FIPS mode initialized and then it gets timed out again.
kk#cloudshell:~$ ssh -i sshkey.pem opc#xx.x.x.x
FIPS mode initialized
ssh: connect to host xx.xx.x.x port 22: Connection timed out
kk#cloudshell:~ $
sshkey.pem is the private key file here to connect to linux server
Same error
user#cloudshell:.ssh (region)$ ssh -vvv opc#168.xxx.xxx.xx
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
FIPS mode initialized
debug2: resolving "168.xxx.xxx.xxx" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 168.xxx.xxx.xxx [168.xxx.xxx.xxx] port 22.
^C
Same error to Private/Public IP
user#cloudshell:.ssh (sa-saopaulo-1)$ ssh opc#192.
FIPS mode initialized

How open-ssh can connect through SOCKS5 proxy on windows (Putty is not an option)?

What I want
shadowsocks connection (SOCKS5)
127.0.0.1:1080 -------> SERVEUR:YYY
(WINDOWS) (LINUX / ARCH)
/ \
ssh sshd
What works
I can ssh login on LINUX from WINDOWS through SOCKS5 proxy using Putty (proxy: SOCKS5 127.0.0.1:1080)
The problem
Visual code does not support putty !
I installed Open-ssh for windows (OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5)
and tried everything I could using ProxyCommand and ncat.exe ... nothing works ...
Ncat 7.91 for windows
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\\Users\\laurentb/.ssh/config
debug1: C:\\Users\\laurentb/.ssh/config line 5: Applying options for home
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolve_canonicalize: hostname 127.0.0.1 is address
debug1: Executing proxy command: exec C:\\Program Files (x86)\\Nmap\\ncat.exe --proxy-type socks5 --proxy 127.0.0.1:1080 127.0.0.1
debug3: spawning "C:\\Program Files (x86)\\Nmap\\ncat.exe" --proxy-type socks5 --proxy 127.0.0.1:1080 127.0.0.1
debug3: w32_getpeername ERROR: not sock :2
debug1: identity file C:\\Users\\laurentb\\.ssh\\remote_auth type 0
debug3: Failed to open file:C:/Users/laurentb/.ssh/remote_auth-cert error:2
debug3: Failed to open file:C:/Users/laurentb/.ssh/remote_auth-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\laurentb\\.ssh\\remote_auth-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
ssh_exchange_identification: Connection closed by remote host
QUESTION
Does anybody managed to log using OpenSSH_for_Windows_7.7p1 ssh through a SOCKS5 proxy and how ?
Thanks..!
I answer my question:
Since putty is working well : use Putty to forward 22 port through SOCKS5
A) proxy :
SOCKS 5
hostname : 127.0.0.1
port:1080
B ) forward port L22 127.0.0.1:22
C) ssh to 127.0.0.1:22
ssh -l "username" 127.0.0.1
You can this way use Remote Visual Studio Code through shadowsocks proxy...

ssh - Control socket does not exist - Operation timed out

When I try to SSH on to my remote desktop from my Mac, I get this error message:
$ ssh -vvvv john#dev-dsk-john.com
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /Users/john/.ssh/config
debug1: /Users/john/.ssh/config line 26: Applying options for *
debug1: /Users/john/.ssh/config line 40: Applying options for dev-dsk*.amazon.com
debug1: /Users/john/.ssh/config line 165: Applying options for *.us-east-*.amazon.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: auto-mux: Trying existing master
debug1: Control socket "/tmp/ssh_mux_dev-dsk-john.com_22_john" does not exist
debug2: resolving "dev-dsk-john.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to dev-dsk-john.com [10.1.133.160] port 22.
debug1: connect to address 10.1.1.1 port 22: Operation timed out
ssh: connect to host dev-dsk-john.com port 22: Operation timed out
The connection hangs at
debug1: Connecting to dev-dsk-john.com [10.1.133.160] port 22.
It was working three days ago.
The system says the host is still active, so I'm pretty sure the computer is still powered on.
I faced the same problem today, and finally managed to fixed it.
I first verified that the control socket really doesn't exist. My path was "/home/ethan/.ssh/controlmasters/ethan#a.b.c.d:22" and this didn't exist.
I then ran ssh like:
ssh -M -S /home/ethan/.ssh/controlmasters/ethan#<ipaddr>:22 server.example.org
Now, it connects and also creates the control socket. Subsequently, I could open another ssh and that didn't require password and things worked normally.

Cannot ssh from Mac OS X to Linux

I have Linaro running in an embedded system (Zedboard). I am using the Mac Terminal to ssh to this system. The Zedboard has an IP. I set it in the interfaces file. This board is not connected to the internet and it is not running any firewall. I cannot ssh to this machine.
$ ssh -vvv root#169.254.218.146
OpenSSH_5.6p1, OpenSSL 0.9.8x 10 May 2012
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 169.254.218.146 [169.254.218.146] port 22.
debug1: connect to address 169.254.218.146 port 22: Connection refused
ssh: connect to host 169.254.218.146 port 22: Connection refused
Shouldn't there be a debug3 for the third verbose? Ping works however. I can ping just fine and it responds. Any help is appreciated. Thank you.
EDIT: I noticed some strange behavior. My very first connection (after booting up Linaro) actually times out.
root#Vinayak’s MacBook Pro ~ $ ssh -vvv root#169.254.218.146
OpenSSH_5.6p1, OpenSSL 0.9.8x 10 May 2012
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 169.254.218.146 [169.254.218.146] port 22.
debug1: connect to address 169.254.218.146 port 22: Operation timed out
ssh: connect to host 169.254.218.146 port 22: Operation timed out
Any SUBSEQUENT ssh's give the connection refused result.
None of the information displayed by the third debug level is relevant here. It displays additional details about the SSH connection, but no connection is being established at all here, so there's nothing to say.
Your output indicates that the Zedboard is not running an SSH server, or it is not configured to accept connections on this IP.