I'm trying to write a script that connect to a linux server by using an other one as a ProxyJump:
ssh -J root@proxyhost root@target I have two different keys (actually ssh certificate) and I would like to tell ssh to use one for the proxy host and the other for the target. I know I could modify the ssh config for that but I would like to specify it on the command line so I don't have to rely on a valid ssh configuration.
So I'm looking for something like:
ssh -i proxyhostkey -J root@proxyhost -i targetkey root@targetThe ssh man page of the -J options says (emphasis mine):
Note that configuration directives supplied on the command-linegenerally apply to the destination host and not any specified jump hosts. Use ~/.ssh/config to specify configuration for jump hosts.
Is it possible to do want I want ? Or do I have to ensure that the ~/.ssh/config file will be correct ?
1 Answer
No, you'll have to either
use two
-iparameters and allow ssh to offer both keys to both servers (the order of-iversus-Jdoesn't matter);or replace
-Jwith a manual ProxyCommand:ssh target -oProxyCommand="ssh proxyhost -i ~/otherkey -W %h:%p" -i ~/thiskey