SSH ProxyJump 应用错误的用户名

SSH ProxyJump 应用错误的用户名

鉴于以下情况ssh.cfg

Host bastion
  Hostname xx.yyy.169.100
  User ubuntu
  IdentityFile ./the-key.pem

Host 10.250.*.*
  ProxyJump %r@bastion
  User core
  IdentityFile ./the-key.pem

通过 尝试连接到服务器bastion失败,因为 ssh 应用了错误的用户名:

$ ssh -vvF ssh.cfg 10.250.198.76
...
debug1: Reading configuration data ssh.cfg
debug1: ssh.cfg line 1: Applying options for bastion
debug2: resolve_canonicalize: hostname xx.yyy.169.100 is address
debug2: ssh_connect_direct
debug1: Connecting to xx.yyy.169.100 [xx.yyy.169.100] port 22.
debug1: Connection established.
debug1: identity file ./the-key.pem type -1
debug1: identity file ./the-key.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to xx.yyy.169.100:22 as 'core'
...

我预计 ssh 将ubuntu在连接到堡垒时应用用户,并且仅core在连接到目标服务器时应用用户。

有没有办法按照我想要的方式配置它?

答案1

%r您输入的部分将ProxyJump替换您当前尝试通过 ssh 访问的远程计算机的用户名 ( core)。您只需要:

ProxyJump bastion

以便它使用您的bastion条目的默认用户名。请参阅OpenSSH 食谱了解更多信息。

相关内容