I'm desperatly trying to find out a way to forward a command to an ESX server in order to power on a virtual machine. This is needed by a backup post-command (a Windows .cmd file) that must be executed on the VCB server to start the VM up after a cold backup.
I'm testing Plink to forward the following command to the ESX server by SSH:
vmware-cmd /vmfs/volumes/47012243-1dadf644-000bcdee702d/VMACHINE/VMACHINE.vmx start
There are 2 problems:
1- I'm not able to understand how forward the command from my batch file to ESX using plink.exe
2- In any case the "vmware-cmd" command needs root's privileges to be executed
I would be grateful if someone would be kind enough to post me some precious suggestions.
You can edit the /etc/ssh/sshd_config file and change PermitRootLogin to yes, save the file then restart the sshd service:
nano -w /etc/ssh/sshd_config
CTL + X (to exit)
Y (to save)
Enter (to overwrite existing file)
then from the console:
service sshd restart
What is the full plink command line you're running?
As root... This will work...
plink -ssh root@vmhost -pw password vmware-cmd /vmfs/volumes/47012243-1dadf644-000bcdee702d/VMACHINE/VMACHINE.vmx start
That is, if root has ssh privileges.
If is doesn't, you'll need to use the -m option, and read your commands from a file. That way, you can ssh as a non-privileged user, SU, and then run your command...
Hope that helps.
Jase
I would consider setting up a limited user using sudo that only has the ability to run vmware-cmd.
Guide to editing the sudo file is here:
http://www.xtravirt.com/index.php?option=com_remository&Itemid=75&func=startdown&id=10
Then you can use plink with the user's password rather than putting the root password in a batch file.
Thanks to all of you. You're very kind.
This is the command I used:
plink -ssh sesxf1.admain.loc -l root -pw rootpsw vmware-cmd /vmfs/volumes/47012243-1dadf644-000bcdee702d/VMACHINE/VMACHINE.vmx start
I think the following is quite the same:
plink -ssh -pw rootpsw vmware-cmd /vmfs/volumes/47012243-1dadf644-000bcdee702d/VMACHINE/VMACHINE.vmx start
They both give me "access denied". I suppose this means that the root hasn't got the right privileges for grant direct access via SSH. Infact, using Putty, I've first to connect as another user and the, by typing the "su -" command, grant access as root.
I'd rather prefer not using the -m option cause it means adding / removing script files in all the esx's server every time I add or remove an host in / from the backup system.
To be honest, I don't know how to logon as user then SU- and finally run my command. Not using a batch file...
Do you know how set root up to grant direct access to SSH without using "SU -" ?
Sorry for being so newbie...
You can edit the /etc/ssh/sshd_config file and change PermitRootLogin to yes, save the file then restart the sshd service:
nano -w /etc/ssh/sshd_config
CTL + X (to exit)
Y (to save)
Enter (to overwrite existing file)
then from the console:
service sshd restart
I modified the sshd_config as merse explained.
Now the command works great!
Thank you very much!
I don't seean /etc/ssh directory. How can we achieve this on ESXi update3?
Senior Hosting Engineer
ModusLink Open Channel Solutions, Inc.