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
相关推荐
linux修理工6 分钟前
ipmitool 使用简介(ipmitool sel list & ipmitool sensor list)
运维·服务器
XM-545811 分钟前
2025微信小程序wxapkg解包全攻略
linux·运维·小程序
朗晴44 分钟前
文本编辑器VIM的使用方法!
linux·运维·服务器
小林up1 小时前
github push:ssh: connect to host github.com port 22
运维·ssh·github
梁bk4 小时前
[Nginx]反向代理和负载均衡
运维·nginx·负载均衡
Leinwin8 小时前
微软开源GitHub Copilot Chat,AI编程领域迎新突破
microsoft·github·copilot
(:满天星:)10 小时前
第31篇:块设备与字符设备管理深度解析(基于OpenEuler 24.03)
linux·运维·服务器·网络·centos
小陶来咯10 小时前
【仿muduo库实现并发服务器】Acceptor模块
运维·服务器
cui_hao_nan10 小时前
Docker后端部署
运维·docker·容器
ZZH1120KQ10 小时前
Linux系统安全及应用
linux·运维·系统安全