diveDylan / blog

My blog, detail is in the issues list
2 stars 0 forks source link

git error: ssh: connect to host github.com port 22: Operation timed out fatal #1

Open diveDylan opened 5 years ago

diveDylan commented 5 years ago

报错信息只简单的描述了几个关键字sshtime out,语义上理解为ssh链接git超时,先尝试正对当前git项目ssh是否还有效,命令行执行如下命令:

$ ssh -T git@github.com
# Attempts to ssh to GitHub

文章: Testing your SSH connection success

Hi xxx! You've successfully authenticated, but GitHub does not # provide shell access.

fail

ssh: connect to host github.com port 22: Operation timed out

更改remote url 为http

文章: Changing a remote's URL

$ git remote -v
# Verify new remote URL
> origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
> origin  https://github.com/USERNAME/REPOSITORY.git (push)

// set remote from http to ssh
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git