1

我正在开始我的项目并使用 github 进行远程回购。

我将操作系统从 Ubuntu 更改为 Xubuntu。

但是我将所有旧文件都复制到了新位置。

我继续使用我需要推动更改的程序。

我生成了新的 SSH 密钥并添加到了 github。

我试图推送更改,但它打印出奇怪的信息:

nazar@nazar-desctop:~/Documents/workspace/NewYearGift$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
nazar@nazar-desctop:~/Documents/workspace/NewYearGift$ sudo git push -u origin master
[sudo] password for nazar:
ssh: Could not resolve hostname github.com: Name or service not known
fatal: The remote end hung up unexpectedly

更新:

我再次重新创建了这个项目,现在它询问我的密码:

nazar@nazar-desctop:~/Documents/workspace/NewYearGift$ git commit -m "correct smole issue"
[master e2cbdec] correct smole issue
 1 file changed, 29 insertions(+), 29 deletions(-)
 rewrite README.md (89%)
nazar@nazar-desctop:~/Documents/workspace/NewYearGift$ git push
Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts.
Enter passphrase for key '/home/nazar/.ssh/id_rsa': 
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 843 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@github.com:nazar-art/NewYearGift.git
   3fb0853..e2cbdec  master -> master

现在它有效,但为什么这么严格?

smb能解释一下吗?

如何解决这个麻烦?

4

3 回答 3

2

无法解析主机名 github.com:名称或服务未知

您需要修复系统的解析器。由于某种原因,它无法解析 github.com 的 IP 地址

于 2013-12-21T15:36:31.610 回答
1

创建 SSH 密钥时,您可以选择为其添加密码。这不是强制性的,但它确实提供了额外的安全层。

系统会提示您输入密码,因为您的密钥有一个。

如果您愿意,可以删除密码,但我建议您改用代理。使用代理时,您可以输入一次密码,并且在一定时间内不会被提升再次输入密码。

根据您的操作系统和桌面环境,您有许多运行代理的选项。OpenSSH 提供了这种方法:

ssh-add -t 5h

这将立即提示您输入密码,然后让您工作五个小时而无需重新输入密码。有关详细信息,请参见手册页

OpenSSHsshd_config可以理解的时间格式可以在.

于 2013-12-21T16:23:40.433 回答
0

确保您的 ssh url 不是使用 scp 语法的

github.com:username/yourRepo

因为如果是,ssh 会寻找一个~/.ssh/config文件来解析“ github.com

Host github.com
  HostName github.com
  User git

您可以使用原始 ssh 网址:

git remote set-url origin ssh://git@github.com/username/yourRepo.git

您也可以尝试切换到 https 网址

git remote set-url origin https://username@github.com/username/yourRepo
于 2013-12-21T15:41:44.897 回答