VMware Cloud Community
g3uiss
Enthusiast
Enthusiast
Jump to solution

Script on vMA to shutdown host

Hi I have created a script on the a vMA to ssh in to Esxi and perform the /sbin/shutdown.sh && /sbin/poweroff.

I have set up password free access to the Esxi with keys.

The scrip is

ssh root@xxx.xxx.xxx.xxx

/sbin/shutdown.sh && /sbin/poweroff

I have added to the vMA sudoers vi-admin:ALL

I run the script with

sudo /home/vi-admin/ups.sh

It stops after each line after loging in to the ESXi....Im missing something here ???

Tony

0 Kudos
1 Solution

Accepted Solutions
schepp
Leadership
Leadership
Jump to solution

Hi,

"ssh root@IP"

will open the session and close it right after.

you can use "ssh root@IP COMMAND" in a single line to open the ssh, run the command and close the connection right after.

Another problem might be, that some commands might not be allowed to be executed from remote because they require a tty. In this case ssh knows the option -t to force a pseudo-ttyp allocation.

Regards

Tim

View solution in original post

0 Kudos
1 Reply
schepp
Leadership
Leadership
Jump to solution

Hi,

"ssh root@IP"

will open the session and close it right after.

you can use "ssh root@IP COMMAND" in a single line to open the ssh, run the command and close the connection right after.

Another problem might be, that some commands might not be allowed to be executed from remote because they require a tty. In this case ssh knows the option -t to force a pseudo-ttyp allocation.

Regards

Tim

0 Kudos