Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2160434

Summary: [Regression] Cannot ssh through ProxyCommand+nc
Product: Red Hat Enterprise Linux 9 Reporter: Renaud Métrich <rmetrich>
Component: nmapAssignee: Martin Osvald 🛹 <mosvald>
Status: CLOSED DUPLICATE QA Contact: František Hrdina <fhrdina>
Severity: medium Docs Contact:
Priority: medium    
Version: 9.1CC: fhrdina
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-01-12 12:35:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Renaud Métrich 2023-01-12 12:17:22 UTC
Description of problem:

Trying to use "nc" to ssh through a HTTP proxy, the connection fails before authenticating on the remote system:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# ssh -o ProxyCommand="nc --proxy vm-proxy9:3128 --proxy-type http %h %p" root@vm-proxy9 true
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This works fine on RHEL8 (nmap-ncat-7.70-8.el8.x86_64) and works fine on Fedora 37 (nmap-ncat-7.93-1.fc37.x86_64).

stracing shows that *nc* connects to the proxy, then just exits, whereas on RHEL8 a select() is performed (to listen on the connection):

- RHEL9

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
3797  11:46:20.705746 socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 3<TCP:[29584]> <0.000022>
3797  11:46:20.705860 connect(3<TCP:[29584]>, {sa_family=AF_INET, sin_port=htons(3128), sin_addr=inet_addr("192.168.122.10")}, 16) = 0 <0.000144>
3797  11:46:20.706089 sendto(3<TCP:[192.168.122.10:56132->192.168.122.10:3128]>, "CONNECT vm-proxy9:8022 HTTP/1.0\r\n\r\n", 35, 0, NULL, 0) = 35 <0.000117>
3797  11:46:20.706309 recvfrom(3<TCP:[192.168.122.10:56132->192.168.122.10:3128]>, "HTTP/1.1 200 Connection established\r\n\r\n", 8192, 0, NULL, NULL) = 39 <0.004072>
3797  11:46:20.710422 write(1<pipe:[29495]>, "", 0) = 0 <0.000003>
3797  11:46:20.710445 dup(3<TCP:[192.168.122.10:56132->192.168.122.10:3128]>) = 4<TCP:[192.168.122.10:56132->192.168.122.10:3128]> <0.000003>
3797  11:46:20.710463 fcntl(4<TCP:[192.168.122.10:56132->192.168.122.10:3128]>, F_GETFL) = 0x2 (flags O_RDWR) <0.000003>
3797  11:46:20.710478 fcntl(4<TCP:[192.168.122.10:56132->192.168.122.10:3128]>, F_SETFL, O_RDWR|O_NONBLOCK) = 0 <0.000003>
3797  11:46:20.710495 close(4<TCP:[192.168.122.10:56132->192.168.122.10:3128]>) = 0 <0.000003>
3797  11:46:20.711424 futex(0x7fb920337bd8, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000004>
3797  11:46:20.711495 exit_group(0)     = ?
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

- RHEL8

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
4947  11:48:27.737068 socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 3<TCP:[272305]> <0.000026>
4947  11:48:27.737190 connect(3<TCP:[272305]>, {sa_family=AF_INET, sin_port=htons(3128), sin_addr=inet_addr("192.168.122.10")}, 16) = 0 <0.000367>
4947  11:48:27.737637 sendto(3<TCP:[192.168.122.184:40534->192.168.122.10:3128]>, "CONNECT vm-proxy9:8022 HTTP/1.0\r\n\r\n", 35, 0, NULL, 0) = 35 <0.000016>
4947  11:48:27.737743 recvfrom(3<TCP:[192.168.122.184:40534->192.168.122.10:3128]>, "HTTP/1.1 200 Connection established\r\n\r\n", 8192, 0, NULL, NULL) = 39 <0.000617>
4947  11:48:27.738412 write(1<pipe:[272267]>, "", 0) = 0 <0.000004>
4947  11:48:27.738438 dup(3<TCP:[192.168.122.184:40534->192.168.122.10:3128]>) = 4<TCP:[192.168.122.184:40534->192.168.122.10:3128]> <0.000004>
4947  11:48:27.738459 fcntl(4<TCP:[192.168.122.184:40534->192.168.122.10:3128]>, F_GETFL) = 0x2 (flags O_RDWR) <0.000004>
4947  11:48:27.738484 fcntl(4<TCP:[192.168.122.184:40534->192.168.122.10:3128]>, F_SETFL, O_RDWR|O_NONBLOCK) = 0 <0.000003>
4947  11:48:27.738503 select(5, [0<pipe:[272266]> 4<TCP:[192.168.122.184:40534->192.168.122.10:3128]>], [], [0<pipe:[272266]> 4<TCP:[192.168.122.184:40534->192.168.122.10:3128]>], NULL) = 1 (in [0]) <0.000005>
4947  11:48:27.738532 recvfrom(0<pipe:[272266]>, 0x7fff77513dd0, 8192, 0, 0x7fff77513d50, [128]) = -1 ENOTSOCK (Socket operation on non-socket) <0.000003>
4947  11:48:27.738552 read(0<pipe:[272266]>, "SSH-2.0-OpenSSH_8.0\r\n", 8192) = 21 <0.000004>
 :
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Version-Release number of selected component (if applicable):

nmap-ncat-7.91-10.el9.x86_64

How reproducible:

Always

Steps to Reproduce:
1. Setup a proxy using Squid

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# systemctl disable firewalld --now
# yum -y install squid
# cat > /etc/squid/squid.conf << EOF
http_access allow all
http_port 3128
EOF

# systemctl start squid
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

2. Perform a local ssh connection through the proxy

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# ssh -o ProxyCommand="nc --proxy localhost:3128 --proxy-type http %h %p" root@localhost true
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Actual results:

Failure

Expected results:

Works

Comment 1 Martin Osvald 🛹 2023-01-12 12:35:34 UTC
Thank you very much for reporting this problem and repro steps!

This is a duplicate of:

Bug 2140101 - ncat does not work with --proxy

and will be fixed with the upcoming setup version in 9.2:

https://brewweb.engineering.redhat.com/brew/buildinfo?buildID=2278331

*** This bug has been marked as a duplicate of bug 2140101 ***

Comment 2 Martin Osvald 🛹 2023-01-12 12:39:19 UTC
oh no, of course not setup but nmap :)