I want to write a script which can Shutdown remote Ubuntu system. Actually i want my VM to shutdown safely when i shutdown my main machine on which my VM is installed .
Is there is any of doing this with the help of Sh scripts or script written in any language like Python.
You can run the following command from a remote Linux machine (VM Host):
You will have to input your root password for the remote machine. You can prevent this by adding ssh certificates (good if you are writing a script):
SSH login without password
If you make a script out of this, don’t forget to add a delay after the shutdown (e.g.
sleep 10) so that the VM will have time to die peacefully.A complete bash script (untested):