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
相关推荐
fyakm几秒前
Linux文件搜索:grep、find命令实战应用(附案例)
linux·运维·服务器
wanhengidc1 小时前
云手机存在的意义是什么
运维·服务器·arm开发·安全·智能手机
snow@li3 小时前
运维:部署Jenkins
运维·jenkins
大海绵啤酒肚4 小时前
OpenStack虚拟化平台之T版搭建部署
linux·运维·云计算·openstack
ZhiqianXia5 小时前
github 软件安全术语
安全·github
The Chosen One9856 小时前
【Linux】Linux权限讲解 :写给文件的一封情书
linux·运维·服务器
苦学编程的谢6 小时前
Redis_3_Redis介绍+常见命令
数据库·redis·github
Thexhy7 小时前
在centos 7上配置FIP服务器的详细教程!!!
linux·运维·centos
FJW0208148 小时前
DevOps——CI/CD持续集成与持续交付/部署的理解与部署
运维·ci/cd·devops
Java 码农8 小时前
Linux shell sed 命令基础
linux·运维·服务器