CONNECT-TUNNEL(1p)
β¨ connect-tunnel β like, the manual page, but make it make sense β¨
okay bestie, so this is the manual page for connect-tunnel, a little Perl script from the User Contributed Perl Documentation section. it's a Perl thing, it's a tunnel thing, and honestly? it's giving main character energy. let's go π
πΈ NAME πΈ
connect-tunnel β create CONNECT tunnels through HTTP proxies. that's the whole vibe. tunnels. through proxies. slay.
π SYNOPSIS π
connect-tunnel [ -Lv ] [ -A user:pass ] [ -P proxy:port ]
[ -C controlport ] [ -T port:host:hostport ]
π DESCRIPTION π
so basically, connect-tunnel sets up tunneled connections to outside hosts, and the way it does that is by redirecting connections to local ports towards those hosts/ports through an HTTP proxy. it's a middleman. a cute little middleman. π§
the trick it uses is the HTTP CONNECT method, which is how it asks the proxy to build a tunnel out to an outside server. but β and this is the important part, no cap β some proxies are set up to deny outside tunnels. that can be a denial for ports other than 443, or a denial for anything outside a specified set of outside hosts. so if it doesn't work, it might not be you, it might be the proxy being a hater. π
β¨ OPTIONS β¨
the program follows the usual GNU command line syntax, with long options starting with two dashes. periodt.
-A,--proxy-authentication user:passwordβ the proxy authentication info, aka your little login moment. π«Ά please note that every authentication scheme supported byLWP::UserAgentis supported here, because we use anLWP::UserAgentinternally to talk to the proxy. iykyk.-C,--control-port controlportβ the port you can connect to in order to issue control commands toconnect-tunnel. see "CONTROL CONNECTIONS" for more deets about which commands are available. yes, it's a remote control. iconic. π-L,--local-onlyβ creates the tunnels so they only listen onlocalhost. so only connections coming from the machine that's runningconnect-tunnelget accepted. lowkey the safest vibe. also, fun fact: this was the default behaviour back inconnect-tunnelversion0.02. the way that changedβ¦ π-P,--proxy proxy[:port]β the proxy is required to connect the tunnels, bestie, it's not optional. if you don't give a port,8080is used by default. see also "ENVIRONMENT VARIABLES" below. π-T,--tunnel port:host:hostportβ this says: the givenporton the local host gets forwarded to the givenhostandhostporton the remote side. how it works: it allocates a socket listening onporton the local side, and every time a connection shows up on that port,connect-tunnelforwards it to the proxy (with the credentials, if they're required), and the proxy forwards it onward to the final destination. teamwork, fr fr. π€
β οΈ heads up: this does not imply the use of any cryptographic system β no SSL, no nothing. this is a simple TCP redirection. whatever security exists, if any, is the security provided by the protocol you're using to connect to the destination through connect-tunnel. so like, don't assume it's encrypted just because it's a tunnel. π
on Unix systems, only root can forward privileged ports. π«
also β you can set up tunnels to multiple destinations by just using the --tunnel option several times. no need to run five of them.
-U,--user-agent stringβ specifies theUser-Agentvalue to send in HTTP requests. the default is to sendconnect-tunnel/version. dress it up however you like. π-v,--verboseβ verbose output. and yes, you can use this option several times for even more verbose output. stacking the vibes. π₯
π EXAMPLES π
okay so say you wanna connect to a SSH server running on ssh.example.com, on port 443, through the proxy proxy.company.com running on port 8080. boom:
connect-tunnel -P proxy.company.com:8080 -T 22:ssh.example.com:443
and now point your favorite ssh client to the machine running connect-tunnel. that's it. that's the whole thing. β¨
you can also emulate a "standard" user-agent:
connect-tunnel -U "Mozilla/4.03 [en] (X11; I; Linux 2.1.89 i586)"
-P proxy.company.com:8080 -T 22:ssh.example.com:443
and connect-tunnel can easily use your proxy credentials to connect outside, no drama:
connect-tunnel -U "Mozilla/4.03 [en] (X11; I; Linux 2.1.89 i586)"
-P proxy.company.com:8080 -T 22:ssh.example.com:443
-A book:s3kr3t
but if you do not want anybody else connecting to your tunnels and going through the proxy with your credentials, use the --local-only option. protect your login bestie!! π
connect-tunnel -U "Mozilla/4.03 [en] (X11; I; Linux 2.1.89 i586)"
-P proxy.company.com:8080 -T 22:ssh.example.com:443
-A book:s3kr3t -L
and if you've got several destinations, there's genuinely no need to run several instances of connect-tunnel:
connect-tunnel -U "Mozilla/4.03 [en] (X11; I; Linux 2.1.89 i586)"
-P proxy.company.com:8080 -A book:s3kr3t -L
-T 22:ssh.example.com:443
-T 222:ssh2.example.com:443
but naturally, you will need to correctly set up the ports in your clients. no skipping that part. π
mmm, such a long command line would perfectly fit in an alias or a .BAT file. ;-) π
π¦ ENVIRONMENT VARIABLES π¦
the environment variable HTTP_PROXY can be used to provide a proxy definition.
and that environment variable gets overriden by the --proxy option, if it's passed to connect-tunnel. so the flag wins. always. π
π AUTHOR π
Philippe "BooK" Bruhat, <book@cpan.org>.
and he says: he seems to have re-invented a well-known wheel with that script, but at least he hopes he added a few interesting options to it. honestly? he did. π«Ά
π SCRIPT HISTORY π
the first version of the script was a quick hack that let him go through a corporate proxy. relatable.
version 0.02 and version 0.03 were released on CPAN in 2003.
version 0.04 sits half-finished in a CVS repository at home β he couldn't decypher the spaghetti of his data structures any more. :-( π literally the most developer thing ever.
version 0.05 (and higher) are based on Net::Proxy, and included with the Net::Proxy distribution.
and even though it's not rocket science, connect-tunnel has been cited in at least one academic work:
- HTTP Tunnels Through Proxies, Daniel Alman
available at SANS InfoSec Reading Room: Covert Channels <http://www.sans.org/rr/whitepapers/covert/>
direct link: <http://www.sans.org/rr/whitepapers/covert/1202.php>
β COPYRIGHT β
Copyright 2003-2007, Philippe Bruhat. All rights reserved.
πΈ LICENSE πΈ
this module is free software; you can redistribute it or modify it under the same terms as Perl itself.
okay bestie that's the whole page, you're officially a tunnel girlie now π the manual page itself is from the perl v5.38.2 docs, dated 2024-05-15, and it lives in the CONNECT-TUNNEL(1p) section. go forth and tunnel. no cap. πβ¨π¦
π¦ where this page comes from
- debian trixie: libnet-proxy-perl 0.13-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-proxy-perl 0.13-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-proxy-perl 0.13-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms