Remotely run vcenter console commands automated.

I have deployed a vCenter 6.0 host using the automated deployment method which has worked fine, now I want to run some commands to join the vcenter to the domain. I have the commands I need but need a way to run these again the vcenter in an automated way - I have tested the commands by accessing the vcenter console with Putty and running them sequentially which work.

What I need is a way to automate the running of these scripts which is compatible with vcenter 6.0, for vcenter 5.5 I used the WinSCP library to upload and then execute a configuration file which worked fine however this doesnt seem to work for vcenter 6.0.

So the question is how can I remotely access the vCenter 6.0 console and run commands in an automated way - what I really need is a way to run these commands from a C# application. Any ideas?
Blowfelt82Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Blowfelt82Author Commented:
OK got a bit further, apparently this is because the vcenter defaul host is not configured to bash. This can be configured via the OVFTool deployment by:

--prop:guestinfo.cis.appliance.root.shell="/bin/bash"

Unfortunately I am not using the OVFTool for deployment so this isnt an option for me, although this does work.

Using SSH this can be set manually (I have used Putty to configure this manually but this is not an automated method). I have also tried using the Tamir.SHarpSSH library to connect using the SSH protocol but this does not work. Is there any way I can configure the default shell as part of the deployment. At the moment it is looking like a chicken and egg situation.

shell.set --enabled True
shell
chsh -s "/bin/bash" root

(Credit goes to William Lam for this).
0
Blowfelt82Author Commented:
Note:

Connecting with Tamir.SharpSSH gives error:

SshShell Ssh = new SshShell("xxx.xxx.xxx.xxx", "root", "mypassword");
Ssh.Connect()

Open in new window


This returns JSchException was unhandled - Algorithm negotiation failed.

I am not sure what this means but it doesnt sound good.
0
gheistCommented:
It means that you use substandard ages old tapir ssh client that does not support 15 years old SSH v2 protocol.
0
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

Blowfelt82Author Commented:
Fair enough, do you know of any freeware ssh libraries I could build into a c# application?
0
gheistCommented:
vsphere powercli ?
google code and sourceforge are  good places to search for freeware....
0
Blowfelt82Author Commented:
Powercli? Can this be used to set the default root - if so that could do the job? Was reading up on Tamir.SharpSSH and it says it supports SSH-2.
0
gheistCommented:
You can set root password from vcenter host profiles. No need to run SSH ever.
0
Blowfelt82Author Commented:
The password is set via the deployment json file, it's the setting of the default shell from the appliancesh shell to bash?
0
gheistCommented:
Ahh... thats virtual machine template... I thought you manipulate ESXi.
You must use vmware studio to add custom attributes, then it can execute commands to apply them within image.
0
Blowfelt82Author Commented:
Managed to solve this. You need to enable the bash shell via a standard SSH connection and then run shell commands by prefixing the bash commands with 'shell {command}'. Changing the BASH shell within the script seems to cause problems with the existing SSH connection.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Blowfelt82Author Commented:
This solution allows SSH connections to run BASH commands directly as needed.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VMware

From novice to tech pro — start learning today.