In our ENV we have 2 jumphost server in which we try to get login and run ssh command on the remote server, we have ssh/confg file for each location with the help of sshproxy we get into the Jump2 server. we want to merge the config file so that we can access all the location server at the same time.
Refer Below ENV
---------> Remote server
Actually we are planning to run a script from my local machine and get the output stored in the local. So for archiving this task we need to do ssh to 2 jumphost and run the below command on remote server, which will run the script form the local machine and get the output on the local machine itself.
Jump1 is accessible via 2222 port user will be the same user
but to access remote server there is a different user1
ssh user1@ip < ./script >> file.txt &&
Set your ~/.ssh/config:
Host Jump1 User jump1user Port 2222 Host Jump2 ProxyCommand ssh -W %h:%p Jump1 User jump2user Host RemoveServer ProxyCommand ssh -W %h:%p Jump2 User remoteUser
With this above file we can directly login to jump2 server without any problem. But we have to change the config file every time for each location.
For running this below example ssh command in a script for gathering information from each region we need a single config file.
ssh jump2 | ssh user1@remoteserver-ip < ./script >> file.txt &&