我试图设置git与http://danielmiessler.com/study/git/#website来管理我的网站。

我已经到了指令的最后一步:git push website +master:refs/heads/master

我正在win7中使用git ming32命令行工作

$ git push website +master:refs/heads/master
Bill@***.com's password:
Connection closed by 198.91.80.3
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

这里的一个问题可能是程序正在寻找bill@* **.com。当我通过ssh连接到我的网站,我有一个不同的用户名(让我们说'abc')。也许这个应该是abc@***。com。如果是这样,我不知道如何改变这一点,或者如果我可以推下一个别名


当前回答

对我来说非常简单的解决方案,见下面:-

问题

$ git clone git@github.com:xxxxx/xxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

这也会超时

$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out

这可能有用

$ ssh -T -p 443 git@ssh.github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

覆盖SSH设置

$ vim ~/.ssh/config

# You can also manually open the file and copy/paste the section below
# Add section below to it
Host github.com
  Hostname ssh.github.com
  Port 443

然后再试一次

$ ssh -T git@github.com
Hi xxxxx! You've successfully authenticated, but GitHub does not
provide shell access.

现在试试克隆(应该有用)

$ git clone git@github.com:xxxxxx/xxxxx.git my-awesome-proj
Cloning into 'my-awesome-proj'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 15 (delta 0), reused 15 (delta 0), pack-reused 0
Receiving objects: 100% (15/15), 22.90 KiB | 4.58 MiB/s, done.

参考:here =>使用端口443的HTTPS

其他回答

您的ssh密钥很可能已从ssh代理中删除

ssh-add ~/.ssh/id_rsa

哪里id_rsa是与git repo相关联的SSH密钥

更新

您可能会得到无法打开到您的身份验证代理的连接。错误,解决您需要首先启动代理的问题:

eval `ssh-agent -s`

2020年10月更新

在大多数情况下,当您有多个用户从同一个客户端系统访问同一个git服务器时,该时间git服务器将访问密钥与用户混淆,但当您发出命令时,它将使用默认用户。

ssh -T git@gitlab.com

看看哪些用户是你想要积极推动的用户

简单的解决方案是从git服务器中删除未使用的用户公钥。

然后试着去取或拉,推它会为我工作

我也面临同样的问题;简单地,你可以在你的命令窗口运行这个:

Git远程添加origin https://your/repository/url

user@server:/etc/nginx$ cat .git/config 
...
[remote "origin"]
    url = git@gitlab.com:user/.git
    fetch = +refs/heads/*:refs/remotes/origin/*
...

使用ssh代替https。 在git中使用ssh密钥(添加ssh密钥)。 如果您是root用户,请使用ssh密钥。


$ sudo ssh-keygen
$ cat /root/.ssh/id_rsa.pub 

$ git init
$ git add file
$ git commit -m "add first file"
$ git remote add origin git@gitlab.com:user/example.git 
$ git push -u origin master

我遇到这个问题是由于多次输入错误的密码。

所以我必须将MaxAuthTries更改为更大的数字:

在服务器端打开sshd_config:

vim  /etc/ssh/sshd_config

更改MaxAuthTries编号:

MaxAuthTries 100    # there I change to 100, you can change to a bigger than your current tries number