I couldn´t find my specific case in other threads.
Basically I have my PC (ubuntu), a proxy (Debian), and a target (Debian). I want to do a proxyjump from the PC to the target going through the proxy. Authentication from the proxy to the target and from the PC to the proxy use pubkey authentication and each machine has its own key pair.
The privkey in the PC matches the PC pubkey in the proxy and they are in the default directory. So, I just run
ssh user@proxy in the PC and it connects fine to the proxy. In the proxy I have to specify
ssh -i mypubkey user@targetserver to connect fine (it´s not the default key).
Now, from the PC, I don´t know how to run one command and end up in the target since I have to specify the privkey in the proxy. I tried:
ssh -J user@proxy user@target ssh -Ao ProxyCommand="ssh -W %h:%p user@proxy" user@target
But it gives me error Permission denied (publickey).
In the proxy server I tried to add the IdentityFile directive in
~/.ssh/config and in
/etc/ssh/ssh_config but apparently when I call the proxy from the PC as the jump host, it won´t take configurations from those files.
If I bring the privkey from the proxy to the PC and I specify with
-i for example, it works (that would be
ssh -i mypubkey -J user@proxy user@target). So my question is: is it possible to keep the privkey in the proxy and reference it in the PC so I don´t have to move it to the PC?