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@target

The ssh man page of the -J options says (emphasis mine):

Note that configuration directives supplied on the command-line generally 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 1


No, you'll have to either

  • use two -i parameters and allow ssh to offer both keys to both servers (the order of -i versus -J doesn't matter);

  • or replace -J with a manual ProxyCommand:

    ssh target -oProxyCommand="ssh proxyhost -i ~/otherkey -W %h:%p" -i ~/thiskey

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .