I am using below two commands to connect to a remote VM host and access the docker bash.
ssh -i ~/.ssh/rsa opc@100.111.99.164
sudo docker exec -it MT bash
First I run ssh -i ~/.ssh/rsa opc@100.111.99.164
which in response connects to the specified Machine and then I run sudo docker exec -it MT bash
inside the terminal of this new machine.
All these I do manually and there are various such instances that I use to connect to, in a day. I want to write a script that automate this process. But the problem is, when I write the aforementioned commands in a .sh file and run it, the second command i.e sudo docker exec -it MT bash
is not executed and that is expected too because the script is not running in the terminal of the machine (100.111.99.164) which I'm connected to.
I would really appreciate if someone could suggest a solution.