How to Configure Git Port Number
A git port number sets the network channel your client uses to reach remote code hosts. You can set it up in your remote URL or SSH settings to route traffic safely. Most teams use standard ports for daily work. Sometimes firewall rules or custom servers need a different setup. Understanding how these ports work helps you fix blocked connections fast. It also helps you keep your code safe during transit. How a git port number works across protocols Git supports a few network protocols to mov
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
A git port number sets the network channel your client uses to reach remote code hosts. You can set it up in your remote URL or SSH settings to route traffic safely.
Most teams use standard ports for daily work. Sometimes firewall rules or custom servers need a different setup. Understanding how these ports work helps you fix blocked connections fast. It also helps you keep your code safe during transit.
How a git port number works across protocols
Git supports a few network protocols to move data between your machine and a server. The protocol you pick decides which port your client uses by default. Most teams use either SSH or HTTPS for all code work.
SSH connections use the configured port by default. When a developer pushes code over SSH, the client talks to the server on that port. You can change this port for one repo by using a full SSH URL. You can also set a host entry in your local SSH config file. That host entry maps a friendly name to a custom port and key.
HTTPS connections use the configured port by default. Web traffic uses this same port, so most corporate firewalls allow it through. If you run an internal Git server on a custom web port, include it in the URL. Both human users and build runners must use this same URL format.
Git also has an older native protocol that uses the configured port. You should avoid this protocol for sensitive code because it lacks built-in login checks. Stick to SSH or HTTPS as your safe default for all users and build jobs.
How to set up custom ports for users and build jobs
When you run a self-hosted Git server, you might move SSH off its default port. Admins often do this to cut down on noise from automated port scanners. Once the server listens on the new port, every client must match that setting.
Git Commit Signing (GPG, SSH) + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
For human engineers, the cleanest method is a local SSH host profile. The engineer adds a short block to their personal SSH settings file. This block tells SSH which hostname, port, and private key to use for that Git host. After that, the engineer can clone and push without typing the port each time.
For automated build jobs and deploy scripts, put the port right inside the repo URL. Build runners start fresh on each run and rarely keep local user files. Putting the port in the full URL makes the job self-contained and easy to read. Make sure the runner also checks the server host key before it connects.
How to check port settings and audit access gaps
When a clone or push fails, check the network path first. Run a basic port check from the client machine to see if the path is open. If the connection drops, a local firewall or cloud network rule might block that port. You can also run your Git command in verbose mode to watch the handshake step by step.
Network logs will show you which IP address connected to your Git port and when. Still, static port rules and local SSH keys leave big gaps after a session starts. Once a key passes the login check, the network firewall does not see what happens next.
Static keys often stay on laptops for months or years without rotation. If an attacker steals a key, they can use the same open port as a real developer. Port rules alone cannot log which specific actions a user runs inside an active session. They also cannot stop someone from pulling all repos at once with a leaked key.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
Which port does Git use by default?
Git uses the configured port for SSH connections and the configured port for HTTPS connections. It also uses the configured port for the legacy Git protocol, which most teams now turn off.
What should I do when a firewall blocks the configured port?
You can switch your remote URL to use HTTPS over the configured port instead. Many major Git hosts also run an SSH server on the configured port to help users bypass strict firewalls.
Does changing the SSH port make my Git server safe?
Changing the port stops basic automated bots from filling up your server logs. It does not replace strong key checks, short session times, or clear audit logs.
Related guides
In this post