1

I read several versions of this question and try to implement them but they did not work so I want to ask my problem with specific details.

Host A: Local Computer

Host B: Intermediate computer ( I can access from my local with using a public key, foo.key

Host C: Final Computer ( I can access it from Host B)

I followed commands like:

ssh -J [email protected] [email protected] 

But where to put key?

When I try something like:

 ssh -i foo.key -J [email protected] [email protected]

It gives error too.

2
  • The actual name for what you're trying to do is an SSH Multi-Hop... see this answer
    – JW0914
    Commented Sep 12, 2019 at 11:59
  • Thanks I read this page too before asking, but any of the examples includes a key file. How can I declare the key file while multi-hopping?
    – usoysal
    Commented Sep 12, 2019 at 12:02

1 Answer 1

3

The general syntax is ssh -J <intermediates> <final>, so according to the information you provided, the actual command should be:

ssh -J user@hostB user@hostC

If using -J or ProxyJump, all connections are made by a locally running client, so all private keys must be available on the local system only.

The -i option only allows specifying the same keys for all connections. If different hosts (e.g. intermediate vs final) need different keys, you'll need to specify them in ~/.ssh/config (or load them into ssh-agent):

Host hostB
    IdentityFile ~/bastion.key

Host hostC
    IdentityFile ~/finalserver.key

(You can specify User user and/or ProxyJump user@hostB in the same file, if you want.)

You must log in to answer this question.

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