Artificial intelligent assistant

Run command over two ssh hops Following AWS best practices I’ve set up an infrastructure to which I ssh via a bastion box: localhost → bastion → target server To connect to the target server I have keyfiles on localhost and the bastion box, and then I use ssh to hop as follows: localhost > ssh -i key.pem bastion bastion > ssh -i key.pem target It looks like this question is related. How do I execute a command on the target server from localhost directly?

You need to use ProxyCommand in your SSH config. So, in case you haven't set up your `~/.ssh/config`, I'd refer to here

So You would want to do the following:

1. Place the bastion as a Forward Agent in your SSH config.

2. Use ProxyCommand to proxy your connection from the bastion to your target server.




Here is a quick example:


Host
ForwardAgent yes

Host
User
Hostname
ProxyCommand ssh -q -W %h:%p @ nc 2> /dev/null
IdentityFile ~/.ssh/id_rsa

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 1f112e5ac7252f0023d64c70faf8e10a