How to SSH directly to target via jumphost using SSH Config without additional ssh command

Solution 1:

You end up logged in to the jump host because your configuration explicitly says to ignore the hostname you specified and log in to the jump host.

  HostName jumphost.example.com

HostName overrides the hostname specified on the command line.

If you are trying to automatically use a jump host without having to specify it on the ssh command line, the correct config file option is ProxyJump. For example:

Host everything, behind, jumphost, *.example.com
  ProxyJump jumphost.example.com

Now you can just run ssh target.example.com and you will go through the jumphost.

Solution 2:

The problem is that the Host definition catches both jumphost.example.com AND target.example.com as aliases, it then sets HostName to jumphost.example.com in both cases.

I would suggest making the aliases following the Host command NOT fully qualified domain names, then creating a Host entry for each

Tags:

Linux

Ssh