Check outbound network ports with Python
WiFi captive portals and public networks often block outbound network port traffic. Sometimes even VPNs are blocked. Often only ports 80 (HTTP) and 443 (HTTPS) are allowed.
For Git, one can use Git with HTTPS and Oauth tokens instead of Git over SSH. However, note that Git over SSH has certain benefits for ease of use and security.
To quickly determine if outbound network ports are blocked, portquiz.net is a useful free service. Using Python automates this process for multiple ports concurrently using concurrent.futures.ThreadPoolExecutor threads or asyncio. We provide an example of each method in short scripts. The examples shows that Asyncio using Semaphore with AIOHTTP can be faster than ThreadPoolExecutor with urllib.request.
Solutions to blocked ports for SSH include using SSH ProxyJump with an intermediate TRUSTED server on an allowed port. Some remote SSH systems actually require this, where they the desired server has only LAN access, and a gateway SSH server with no privileges is used as the SSH ProxyJump by network design.
The ultimate workaround would be a mobile hotspot (different network).