git GitLab 错误:连接被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20558776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GitLab Error: Connection Refused
提问by JT9
I have a cloud server from Digital Ocean that is hosting GitLab
.
我有一个来自 Digital Ocean 的云服务器托管GitLab
。
Whenever I try to create a repository and push it to GitLab, I am getting the following error :
每当我尝试创建存储库并将其推送到 GitLab 时,都会收到以下错误:
ssh: connect to host localhost port 22: Connection refused
fatal: The remote end hung up unexpectedly
ssh:连接到主机 localhost 端口 22:连接被拒绝
致命:远程端意外挂断
I am fairly new to git so I am confused why I keep getting this error. I also have generated and added my SSH key to GitLab. Here are the steps I take to create the repository (per GitLab's instruction):
我对 git 相当陌生,所以我很困惑为什么我一直收到这个错误。我还生成了我的 SSH 密钥并将其添加到 GitLab。以下是我创建存储库的步骤(根据 GitLab 的说明):
mkdir test
cd test
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@idAddress
git push -u origin master
Any suggestions?
有什么建议?
回答by Nick
You can test your SSH key authentication with:
您可以使用以下方法测试您的 SSH 密钥身份验证:
$ ssh -T [email protected]
$ ssh -T [email protected]
Check that your public key is saved in your Gitlab profile, and make sure no newlines are present in the string. Then check that git is using your correct private key if you have more than one.
检查您的公钥是否保存在您的 Gitlab 配置文件中,并确保字符串中不存在换行符。如果您有多个私钥,请检查 git 是否使用了正确的私钥。
Also consider that Gitlab may require the repository to exist; the push won't create a new repo.
还要考虑 Gitlab 可能需要存储库存在;推送不会创建新的回购。
回答by kostix
localhost port 22: Connection refused
本地主机端口 22:连接被拒绝
Means Git tried to connect to SSH (port 22
) to your local host (localhost
), and nothing was listening on that port — hence Connection refused
.
意味着 Git 尝试将 SSH(端口22
)连接到您的本地主机(localhost
),并且没有在该端口上侦听任何内容 - 因此Connection refused
.
You mention ipAddress
in your setup, is it 127.0.0.1
?
你ipAddress
在你的设置中提到了,是127.0.0.1
吗?