4

Let's say I have two servers: jump and target. On jump I have:

jump:~/.ssh/config:

Host target User targetuser HostName actual-target-hostname.fqdn IdentityFile ~/.ssh/target_rsa 

... and on my client machine I want to do ssh -J jump target. However, this doesn't work because once the connection to jump is established, ssh is attempting to connect to target directly rather than use the properties in the config file above. How do I get it to load/use that config file? I don't want to have to distribute that (large) config file to the (many, many) client machines, I'd rather just have that config defined once on the jump host.

2 Answers 2

1

I had upvoted this question before I finished digging through the rest of the Internet because I have a similar issue with trying to get the proxy/bastion to use a different username for the target. It turns out that each ssh connection/command/config option will only use the originating client's configuration/command/config options.

In my case, I wanted to go

username@local -> root@proxy -> admin@target 

with just ssh target

using this config on local:

Host * AddKeysToAgent yes IdentitiesOnly yes IdentityFile ~/.ssh/id_ed25519 User username ForwardAgent yes Host proxy [proxy's IPv4] Hostname [proxy's FQDN] User root Host target [target's IPv4] Hostname [target's FQDN] User admin ProxyJump proxy 

Unfortunately, it would invariably use the wrong username and it took me a while to figure it out, because username exists on all three hosts.

The fix for me was to move Host * to the end of the config. Apparently, I have been mistakenly thinking that later directives would override * and they do not 😁

You will need to have the target's necessary config included in your client and perhaps configure agent forwarding, etc.

0

This was originally a solution to a host-based auth problem of mine, but should apply here as well.

Essentially, we need an easy way of replicating the process of "user manually logs into jump, then into target". This can be done marginally less manually with ssh -t jump ssh target — and while it feels a bit hacky, that process can be specified in your SSH config file as:

Host target HostName jump RemoteCommand ssh target RequestTTY yes 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.