今天本地Git Push 代码推送远程分支,提示如下错误信息:
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ git push
ssh: Could not resolve hostname github.com: No address associated with hostname
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Google 一下,大家的建议是重新配置ssh Key。
重新生成GitHub SSH Key 值,请参考如下指令
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ git config user.name
zhouzhiwengang
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ git config user.email
zhouzhiwengang@163.com
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ ssh-keygen -t rsa -C "zhouzhiwengang@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/zzg/.ssh/id_rsa):
/c/Users/zzg/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/zzg/.ssh/id_rsa
Your public key has been saved in /c/Users/zzg/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:ikXfYyRhWd/897SdPdU+Q/NKTgoZVFm4a4/4qzICidw zhouzhiwengang@163.com
The key's randomart image is:
+---[RSA 3072]----+
| oo. .+. |
| ... ooo |
| . . o ..o |
| . . = . ..|
| . o .. S = . o*|
| o Eo . . +o .o@|
| ... oo oo**|
| . o ...=..+|
| . o.o+.o |
+----[SHA256]-----+
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ eval $(ssh-agent -s)
Agent pid 909
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ ssh-add /c/Users/zzg/.ssh/id_rsa
Identity added: /c/Users/zzg/.ssh/id_rsa (zhouzhiwengang@163.com)
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ clip < /c/Users/zzg/.ssh/id_rsa.pub
执行以上指令完成本机SSH Key值生成,并将生成的Key 拷贝至Git 账户/Setting/SSH key 设置。
温馨提示:SSH Key 生成时,会提示本地已经存在是否覆盖,选择y,再Enter回车。
重新尝试git 代码推送
zzg@LAPTOP-8R0KHL88 MINGW64 /e/idea_workspace (master)
$ ssh -T git@github.com
ssh: Could not resolve hostname github.com: No address associated with hostname
错误含义:域名解析无法找到GitHub.
Google 一下,大家的解决办法时,将GitHub IP地址配置至hosts文件。
解决Github 域名方法问题:
第一步:查询Github 真实IP地址,可以通过 https://www.ipaddress.com/查询。
第二步:在本机:C:\Windows\System32\drivers\etc\hosts 文件中,添加如下配置:文章来源:https://www.toymoban.com/news/detail-471182.html
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
140.82.113.4 github.com
至此,我的Git代码推送恢复正常。文章来源地址https://www.toymoban.com/news/detail-471182.html
到了这里,关于Git提示:ssh: Could not resolve hostname github.com: No address associated with hostname的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!