git - Git : "ssh: connect to host gitlab port 22: connection refused" 的问题

标签 git ssh gitlab push

我正在一家公司写我的学士论文,并从管理员那里获得了 gitlab 的访问权限,但我是 Git 的新手。我为我的论文创建了一个新项目。我的电脑上已经有一个文件夹,里面有一些东西。我在 git bash 中使用了以下命令(按照 gitlab 的推荐):

git init
git remote add origin git@gitlab:USER/TITLE.git
git add [stuff]
git commit
git push -u origin master

提交成功,但最后一个命令产生了错误

"ssh: connect to host gitlab port 22: Connection refused fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists."



我试图切换到端口 443,因为显然这是一回事。
ssh -T -p 443 git@altssh.gitlab.com

这让我:

"The authenticity of host '[altssh.gitlab.com]:443 ([35.190.168.187]:443)' can't be established.
ECDSA key fingerprint is [...].
Are you sure you want to continue connecting (yes/no/[fingerprint])?"



输入 yes 后:

"Warning: Permanently added '[altssh.gitlab.com]:443,[35.190.168.187]:443' (ECDSA) to the list of known hosts.
git@altssh.gitlab.com: Permission denied (publickey)."



返回端口 22 时,连接超时。
push命令后的错误还是一样。

根据 canyouseeme.org,端口 22 和 443 未打开。

我还尝试为 Windows Defender 防火墙菜单中的端口制定新规则。

还是一样的错误。
我真的很感激你的任何帮助或想法:)

彼得

最佳答案

我解决了,没那么难。
ssh 不行,这里大家都用http。
我从 gitlab 复制了错误的 url。

我必须使用的命令是:

git remote set-url origin http://gitlab/USER/PROJECT.git

关于git - Git : "ssh: connect to host gitlab port 22: connection refused" 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58416740/

相关文章:

git - 在 GitLab Pipelines 中,有没有办法在分离 merge 请求时运行管道?

Jenkins 管道自动分支检测

openshift - 将 docker-compose 容器移动到 openshift V3

windows - 如何在具有跨平台兼容性的 Git 提交中强制执行一致的行结尾

windows - 配置 git 以支持使用不同操作系统的程序员

java - ssh客户端如何区分文本颜色

unix - 使用本地环境中的变量执行单行 ssh 命令

git - 你如何在 GitHub 上创建自己的仓库?

git - 如何 'git commit'单个文件/目录

用于安全传输的 Bash 脚本