ssh - Gitlab:无法在家中进行 SSH(Windows)

标签 ssh gitlab vpn

我无法通过家用 PC 让 SSH 为 GitLab 工作。

要清楚:
1. SSH 在同一台机器上对 BitBucket 工作正常
2. SSH key 已添加且正确
3. 我通过 VPN 连接(工作中)

当我尝试使用 -v -v -v 参数连接时,我得到以下输出:

$ ssh git@[server] -v -v -v
OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
debug1: Reading configuration data /c/Users/[me]/.ssh/config
debug2: ssh_connect: needpriv 0
debug1: Connecting to [server] [ip] port 22.
debug1: connect to address [server] port 22: Attempt to connect timed ` out wssh: connect to host [server] port 22: Bad file number

这可能是服务器配置问题吗?

编辑:

我生成了一个新 key 并配置了 ssh 来使用它。
这是输出:
$ ssh -Tvv git@[server]
OpenSSH_6.6.1, OpenSSL 1.0.1i 6 Aug 2014
debug1: Reading configuration data /c/Users/[me].ssh/config
debug1: /c/Users/[me]/.ssh/config line 5: Applying options for [server]
debug2: ssh_connect: needpriv 0
debug1: Connecting to [server] [IP] port 22.
debug1: connect to address [IP] port 22: Attempt to connect timed out without establishing a connection
ssh: connect to host [server] port 22: Bad file number

最佳答案

SSH works fine for BitBucket on the same machine SSH key has been added and is correct



我希望它不是添加到 GitLab 的同一个 ssh key ,而是一个不同的公共(public) key (对于相应的不同私有(private) ssh key )

在这种情况下,您需要一个 ~/.sssh/config 来引用两个公钥,如“How to set up two SSH keys for two GitLab accounts and push/pull by using TortoiseGit? ”:
# my primary account for BitBucket
Host bitbucket
    User git
    HostName bitbucket.com
    PreferredAuthentications publickey
    IdentityFile C:/Users/{username}/.ssh/id_rsa1

# for GitLab server
Host gserver
    User git
    HostName {server}
    PreferredAuthentications publickey
    IdentityFile C:/Users/{username}/.ssh/id_rsa2

同时,检查以下输出:
ssh -Tvv gserver

(“gserver”是 .ssh/config 文件的条目,它引用正确的私有(private) ssh key ,用户“git”)

关于ssh - Gitlab:无法在家中进行 SSH(Windows),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30958010/

相关文章:

linux - SSH 权限被拒绝(密码)

git - 致命的 : could not read Username for 'https://gitlab.com' : terminal prompts disabled

docker - 在 CI 中使用来自 gitlab Registry 的图像

bash - 将特定文件类型从一台主机复制到另一台主机

shell - 如何在 macOS 上一行生成并复制 SSH key ?

shell - 需要查看24小时内哪些文件已更改并发送电子邮件(Shell脚本)

github - 如何直接从 git master 分支部署 Web 应用程序

azure - 刷新 Windows Azure VPN 隧道

java - 如何伪装窃听接口(interface)流量

react-native - 如何使用 React Native 制作一个 vpn 应用程序