github | ssh拉取github仓库报错connect to host github.com port 22: Connection refused

配置ssh key

通过 ssh key 解决本地和服务器连接的问题

bash 复制代码
$ cd ~/. ssh #检查本机已存在的ssh密钥

如果提示 No such file or directory 则表示第一次使用git

输入:

bash 复制代码
ssh-keygen -t rsa -C "邮件地址"

并且连续3次回车,最终会生成一个文件,找到 ssh\id_rsa.pub 文件,打开并复制里面的内容。然后打开你的github主页,进入个人设置 -> SSH and GPG keys -> New SSH key:

创建下面内容


配置完成后输入 ssh -T git@github.com 验证是否配置成功,结果常出现报错如下:

bash 复制代码
ssh: connect to host github.com Port : 22 Connection refused

解决方法如下:

bash 复制代码
# 在终端输入以下命令:
cd ./.ssh
sudo touch config
sudo gedit config

在config文件中写下面的信息:

bash 复制代码
Host github.com  
User xxxxx@xx.com  	// 注册github的邮箱
Hostname ssh.github.com  
PreferredAuthentications publickey  
IdentityFile ~/.ssh/id_rsa  
Port 443
相关推荐
数智顾问1 小时前
(123页PPT)华为流程管理体系精髓提炼(附下载方式)
运维·华为
yuanyuan2o22 小时前
Git merge 的几种不同模式
git·github
AC赳赳老秦4 小时前
财务报销自动化:用 OpenClaw 自动识别发票信息、填写报销单、校验报销规则,减少手工操作
运维·网络·eclipse·github·visual studio·deepseek·openclaw
无限进步_4 小时前
二叉搜索树完全解析:从概念到实现与应用场景
c语言·开发语言·数据结构·c++·算法·github·visual studio
倔强的石头1065 小时前
【Linux 指南】文件系统系列(一):磁盘底层原理 —— 从物理结构到 CHS与LBA 寻址全解析
linux·运维·服务器
陶然同学6 小时前
【Linux及Shell】VMware&Ubuntu&Xshell安装
linux·运维·xshell8·xftp8
小乐笙6 小时前
笔记:纯真 IP 库使用
运维·网络·tcp/ip
咖喱o6 小时前
DHCP
linux·运维·服务器·网络
IMPYLH7 小时前
Linux 的 touch 命令
linux·运维·服务器·bash