Accepting SSH on port 443 as well: Ubuntu 24.04 and Windows OpenSSH setup
Some networks block outbound port 22 and leave only 443, the web port, open. Run ssh against a remote VM from such a network and it waits for a long time, then times out. If the serverâs SSH daemon (sshd) accepts 443 alongside 22, you can reach the same server on 443.
This article keeps port 22 and adds 443. It first checks whether port 22 is really whatâs blocked, then walks through the setup on Ubuntu 24.04 and on Windows OpenSSH Server, and finishes with the clientâs ssh_config. Commands and behavior follow the OpenSSH, Ubuntu, and Microsoft documentation as of 2026-11-17.
Running coding agents on a remote VM and attaching over SSH is covered in the Herdr and Windows over SSH article. This one covers the SSH connection underneath.
At a glance
Section titled âAt a glanceâYou are giving sshd a second door. The existing door on 22 stays, and a new one opens on 443. Opening the door isnât enough on its own: the server firewall and the network rules in front of the server also have to let 443 through.
| Where | What to do | Ubuntu 24.04 | Windows |
|---|---|---|---|
sshd config | Add Port 443 | Drop-in in /etc/ssh/sshd_config.d/ | Top of %ProgramData%\ssh\sshd_config |
| Apply the config | Refresh listening ports | daemon-reload, restart ssh.socket | Restart the sshd service |
| Server firewall | Allow inbound 443 | ufw | Windows Defender Firewall rule |
| Network in front of the server | Allow inbound 443 | Cloud security group, router, and so on | Same |
| Client | Specify the port | ssh -p 443 or ~/.ssh/config | Same |
1. Check whether port 22 is really blocked
Section titled â1. Check whether port 22 is really blockedâThese are the errors you usually see when port 22 is blocked.
kex_exchange_identification: read: Operation timed outbanner exchange: Connection to my-vm.example.com port 22: Operation timed outOnce the TCP connection is up, an SSH server speaks first and sends its version string (the banner). This error means the banner never arrived after the TCP connection. Connect to port 22 with nc and wait a few seconds to see whether a banner shows up.
nc -v my-vm.example.com 22A healthy server prints a line such as SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.20 right away. Read the result like this.
| Result | Meaning |
|---|---|
| Banner appears right away | The network is fine. Look at authentication or client settings |
| The connection itself times out | Packets donât reach the server. Look at firewalls and network rules |
| Connects, but no banner | A device in the middle accepts the connection without passing SSH through, or the serverâs sshd canât respond |
Connection refused | The packet reached the server, but nothing listens on that port |
Trying a port the server doesnât use helps spot a device in the middle. If even an unused port connects, something between you and the server is accepting the connection.
nc -vz -w 5 my-vm.example.com 12345Also try from a different network, such as a phone hotspot. If the banner arrives right away there, the server is fine and the network you normally use is blocking port 22.
2. Adding 443 on Ubuntu 24.04
Section titled â2. Adding 443 on Ubuntu 24.04âKeep one existing SSH session open while you change the settings. If something goes wrong, you can roll back from that session.
Check that 443 is free
Section titled âCheck that 443 is freeâsudo ss -tlnp | grep ':443 'This should print nothing. If a web server such as nginx already uses 443, this approach wonât work.
Add the port with a drop-in file
Section titled âAdd the port with a drop-in fileâUbuntuâs default /etc/ssh/sshd_config reads the sshd_config.d directory at the very top. Check that line and the current Port settings first.
grep -n '^Include\|^Port' /etc/ssh/sshd_configIf Include /etc/ssh/sshd_config.d/*.conf is there, put the ports in a separate file.
printf 'Port 22\nPort 443\n' | sudo tee /etc/ssh/sshd_config.d/10-ports.confsudo sshd -t && echo CONFIG_OKPort can appear more than once, and sshd listens on every port listed. Once you list any Port, though, the default 22 is no longer added for you, so include Port 22 as well. If the main file already has an uncommented Port 22, put only Port 443 in the drop-in.
Make ssh.socket pick up the change
Section titled âMake ssh.socket pick up the changeâSince Ubuntu 22.10, OpenSSH runs with systemd socket activation. Port 22 is held by systemdâs ssh.socket, not by sshd, and sshd starts when a connection arrives. On Ubuntu 24.04, a systemd generator reads the port and address settings from sshd_config to build the socket configuration. Thatâs why restarting only the ssh service doesnât open the new port.
if systemctl is-active --quiet ssh.socket; then sudo systemctl daemon-reload sudo systemctl restart ssh.socketelse sudo systemctl restart sshfidaemon-reload reruns the generator, which builds a socket configuration that includes 443. On a server that has turned socket activation off and runs the old way, restarting the ssh service is enough.
Check the firewall and the result
Section titled âCheck the firewall and the resultâIf ufw is enabled, allow 443.
sudo ufw status | grep -q 'Status: active' && sudo ufw allow 443/tcpCheck that both 22 and 443 are in LISTEN state and that 443 returns an SSH banner. With socket activation, the process in the ss output is systemd, not sshd. Thatâs expected.
sudo ss -tlnp | grep -E ':(22|443) 'timeout 5 nc 127.0.0.1 4433. Adding 443 on Windows OpenSSH Server
Section titled â3. Adding 443 on Windows OpenSSH ServerâRun these steps in an elevated PowerShell. Windows Server 2025 ships with OpenSSH Server installed. On Windows 11 and other versions, check whether itâs installed first.
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH.Server*'If State is NotPresent, install it and start the service. The config file is created the first time the service starts.
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0Start-Service sshdSet-Service -Name sshd -StartupType AutomaticCheck that 443 is free
Section titled âCheck that 443 is freeâGet-NetTCPConnection -LocalPort 443 -State Listen -ErrorAction SilentlyContinueThis should print nothing. If a web server such as IIS already uses 443, this approach wonât work.
Put the ports at the top of the config file
Section titled âPut the ports at the top of the config fileâOn Windows, sshd reads %ProgramData%\ssh\sshd_config. The default file has #Port 22 commented out and ends with a Match Group administrators block for the administrators group. In sshd_config, settings after a Match line apply only to that block, up to the next Match line or the end of the file. So donât append Port to the end of the file; put it at the top.
$f = "$env:ProgramData\ssh\sshd_config"Copy-Item $f "$f.bak"Set-Content -Path $f -Value (@('Port 22', 'Port 443') + (Get-Content $f)) -Encoding ascii& "$env:WINDIR\System32\OpenSSH\sshd.exe" -t; if ($LASTEXITCODE -eq 0) { 'CONFIG_OK' }If you already use an uncommented Port 22, add only Port 443.
Add a firewall rule and restart the service
Section titled âAdd a firewall rule and restart the serviceâInstalling OpenSSH Server creates a firewall rule for port 22 (OpenSSH-Server-In-TCP). Port 443 needs its own rule.
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP-443' -DisplayName 'OpenSSH Server (sshd) 443' ` -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 443sshd reads its config file when the service starts, so restart it to apply the change.
Restart-Service sshdGet-NetTCPConnection -LocalPort 22,443 -State Listen4. Open the network rules in front of the server
Section titled â4. Open the network rules in front of the serverâEven with the server firewall open, packets wonât arrive if a rule in front of the server blocks them. For a cloud VM, add an inbound allow rule for 443 to its security group or network firewall. For a server at home or in an office, add it on the router. Limit the source to the public IP of the client that will connect. If the client moves between networks, you need the egress IP of each one.
If the âconnection itself times outâ row from section 1 also shows up on 443, the source IP in this step usually doesnât match.
5. Connect from the client
Section titled â5. Connect from the clientâConnect with the port specified and check that the banner arrives.
ssh -v -p 443 vmuser@my-vm.example.comIf the -v output contains a line such as Remote protocol version 2.0, remote software version OpenSSH_9.6p1 Ubuntu-3ubuntu13.20, the SSH handshake over 443 worked. get_agent_identities: ssh_get_authentication_socket: Connection refused in the same output is a debug message saying the client couldnât reach its ssh-agent socket. It has nothing to do with the server or the port, and ssh carries on authenticating with key files.
ssh_config takes one Port per Host
Section titled âssh_config takes one Port per HostâWriting two Port lines for one Host in ~/.ssh/config doesnât make ssh fall back to 443 when 22 fails. For each setting, ssh uses the first value it obtains and ignores the rest. To use both ports, split them into two aliases.
Host my-vm HostName my-vm.example.com User vmuser Port 22
Host my-vm-443 HostName my-vm.example.com User vmuser Port 443To pick the port automatically, use Match exec. The block applies when the command exits with status 0. Because the first obtained value wins, put the Match block above the Host block. The following example, for macOS, uses 443 only when the route to the destination goes through a utun tunnel interface.
Match originalhost my-vm exec "route -n get %h 2>/dev/null | grep -q 'interface: utun'" Port 443
Host my-vm HostName my-vm.example.com User vmuser Port 22%h is replaced with the host name being connected to. You can check which port applies without connecting.
ssh -G my-vm | grep -E '^(hostname|port) '- If a web server uses 443, this approach wonât work. This article doesnât cover sharing one port between HTTPS and SSH (sslh and similar).
- On networks that inspect content rather than port numbers and block the SSH protocol itself, 443 is blocked too. In that case the âconnects, but no bannerâ row from section 1 shows up on 443 exactly as on 22.
- If blocking port 22 is an organizationâs policy, getting around it on 443 can break that policy. Ask the administrator for an exception, or look at official paths such as a cloud consoleâs connection feature or a bastion first.
- The Ubuntu steps were confirmed up to a working SSH handshake on 443 against an Ubuntu 24.04 server. The Windows steps follow Microsoftâs documentation and the Win32-OpenSSH default config file, and werenât run on an actual VM.
In this article, OpenSSH accepts SSH connections directly on port 443. What Changes When stunnel Wraps SSH in TLS? compares that setup with TLS termination in stunnel and explains how authentication differs.