Git `host.name.edu:XXXX`对于`.ssh/config`文件来说是无效格式吗?
我遇到了一个奇怪的情况,它告诉我的IT使用ssh URL中的端口连接到git服务器。我的原始ssh配置如下所示:Git `host.name.edu:XXXX`对于`.ssh/config`文件来说是无效格式吗?,git,ssh,ssh-config,Git,Ssh,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@我的主机别名/path/to/repo.git。我在配置中遇到了一些奇怪的身份验证错误(尽管基本功能仍在运
Host my-host-alias
HostName redacted.redacted.edu
Port 2222
User git
IdentityFile ~/.ssh/my-ssh-private-key
我使用的是git远程urlssh://git@我的主机别名/path/to/repo.git
。我在配置中遇到了一些奇怪的身份验证错误(尽管基本功能仍在运行),所以它指示我使用git远程urlssh://git@redacted.redacted.edu:2222/path/to/repo.git
,它似乎与手动指定的git\u SSH\u命令='SSH-i~/.SSH/my private SSH key
一起工作。因此,我重新配置了我的.ssh/config,如下所示:
Host redacted.redacted.edu:2222
IdentityFile ~/.ssh/my-ssh-private-key
突然之间,ssh似乎再也无法解析主机条目了。如果我运行ssh-Tvvvssh://git@redacted.redacted.edu
我得到以下输出(代码段):
似乎在URL中指定带有端口的主机会中断对.ssh/config的解析。有人能验证一下吗?不会使用~/.ssh/config
使用的,来自,早于(2005年1月最终确定)
因此,如果您想使用
.ssh/config
,您需要使用我的主机别名:path/to/repo.git
,您的第一个配置对我来说很好。我不知道由于您没有指定,您得到了什么奇怪的身份验证错误
。您不需要让他们手动传递用户名:git clone my host alias:path/to/repo.git
就足够了。是的,host:port
是ssh配置中host
行的错误格式。@ArkadiuszDrabczyk验证错误与.ssh/config问题无关。显式指定用户没有任何问题,尽管我怀疑如果存在user
,它会被配置文件覆盖。@torek您能告诉我在openssh文档中对格式有这样的约束吗?它不是约束。也就是说,这并不是说它在语法上是错误的。当ssh查找行时,它只使用主机名。所以如果您使用sshuser@host:port命令…
或在本例中为ssh://user@主机:port/path/to/repo.git
,ssh只查找主机
,而不查找主机:port
;字符串host:port
与字符串host
不匹配,ssh将转到下一个配置条目。
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 *