---
title: "20240320-配置GitHub-SSH默认使用443端口"
source: https://www.iowill.com/blog/2024/09/github-ssh-port-443/
date: 2024-09-20
updated: 2026-10-14
tags: [Git, GitHub, SSH, 网络配置]
categories: [软件与工具]
---

# 20240320-配置GitHub-SSH默认使用443端口

当访问 GitHub.com 的 SSH 22 端口受网络规则限制时，可以尝试通过 `ssh.github.com:443` 连接。这里仍然使用 SSH 协议，443 是连接端口；HTTP 代理或只允许 HTTPS 流量的网络仍可能拦截它。

本文假定你已经生成 SSH 密钥并把公钥添加到对应 GitHub 账号。该入口面向 GitHub.com，不适用于 GitHub Enterprise Server 或带数据驻留的 GitHub Enterprise Cloud。配置与范围见 [GitHub 官方说明](https://docs.github.com/en/authentication/troubleshooting-ssh/using-ssh-over-the-https-port)。

## 1.测试443端口是否可用

首先测试一下使用443端口进行GitHub SSH连接：

```shell
ssh -T -p 443 git@ssh.github.com
```

首次连接可能要求确认主机密钥，先与 [GitHub 公布的 SSH 指纹](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints)核对。认证成功时会看到类似输出，其中 UserName 是你的账号名：

> Hi UserName! You’ve successfully authenticated, but GitHub does not provide shell access.

这条提示说明认证成功；GitHub 不提供交互式 Shell 是正常行为。若出现 `Permission denied (publickey)`，应检查使用的密钥和账号授权。

## 2.配置SSH使用443端口

**SSH客户端配置文件**

```shell
# 全局配置文件：/etc/ssh/ssh_config
# 用户配置文件：~/.ssh/config # 如果不存在则创建
```

优先编辑当前用户的 `~/.ssh/config`（Windows OpenSSH 通常位于用户目录下的 `.ssh/config`）。如果已有 `Host github.com` 配置，请检查并合并对应项：

```plaintext
Host github.com
  Hostname ssh.github.com
  Port 443
  User git
```

再次测试是否有效：

```shell
ssh -T git@github.com
```

或拉取仓库：

```shell
git clone git@github.com:UserName/RepoName.git
```
