I have vagrant boxes configured on a remote server (my-server
in my example). I'm trying to run a set of remote commands on a vagrant box, from my machine, through an SSH session:
ssh me@my-server << "ENDSSH"
cd /dir/to/vagrant
vagrant status my_box
vagrant ssh my_box -- "ls"
echo "Good bye!"
ENDSSH
The first 3 commands are executed correctly, but the forth command is never executed. After the output of vagrant ssh my_box -- "ls"
is printed, the SSH session is closed. This happens for any command that I attempt to run on my_box
.
If I create a script containing the above commands, log into my-server
and run the script manually, all the commands are executed including echo "Good bye!"
.
Is it possible that the vagrant ssh my_box -- "ls"
produces an EOF
which terminates the ssh session? Is there anyway to somehow catch the EOF
token and then continue with the script?
Note:
This question relates to another question I asked regarding bamboo. The plugin in bamboo I used to execute remote commands produces an Broken transport; encountered EOF
error after executing some remote tasks.