"host.name.edu:XXXX"是".ssh/config"文件的无效格



我有一个奇怪的情况,告诉我的IT使用ssh URL中的端口连接到git服务器。我最初的ssh配置如下:

Host my-host-alias
HostName redacted.redacted.edu
Port 2222
User git
IdentityFile ~/.ssh/my-ssh-private-key

我使用的是git远程urlssh://git@my-host-alias/path/to/repo.git。我在该配置中遇到了一些奇怪的Auth错误(尽管基本功能仍在运行(,所以IT指示我使用git远程urlssh://git@redacted.redacted.edu:2222/path/to/repo.git,这似乎可以使用手动指定的GIT_SSH_COMMAND='ssh -i ~/.ssh/my-private-ssh-key。因此,我重新配置了.ssh/config,如下所示:

Host redacted.redacted.edu:2222
IdentityFile ~/.ssh/my-ssh-private-key

突然之间,ssh似乎再也无法解析Host条目了。如果我运行ssh -Tvvv ssh://git@redacted.redacted.edu,我会得到以下输出(片段(:

debug1: /Users/myuser/.ssh/config line 94: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: /etc/ssh/ssh_config line 52: Applying options for *

在URL中指定一个带有端口的主机似乎会中断.ssh/config的解析。有人能验证这一点吗?

SSH URI语法不会使用~/.ssh/config

OpenSSH(1999(使用的SCP语法,从SSH协议的历史来看,早于URI(与RFC 39862005年1月最终确定(

因此,如果要使用.ssh/config,则需要使用my-host-alias:path/to/repo.git

最新更新