I have written a batch file to set the IP address of a host server and the two virtual machines running on it. At the moment you have to copy the script onto each machine and run it which isn't what I want, I would like to run the script on the host server and have the commands passed to each VM.
Is this possible?
You could make a powershell script which uses PsExec(comes with sysinternals) to run a scriptblock or script file on your vm machine.
It will look something like this:
PSExec \RPC001 -i -u myID -p myPWD PowerShell C:\script\StartPS.ps1
Apparantly targetting a VM could be more tricky, see this link for more information:
Is there a way to psexec into my own virtual machine (windows xp mode)?
Related
I have local Windows 10 and remote Ubuntu server.
I want to automate connection to server and write executable script witch connects by ssh to server and open new terminal from another server.
What it's supposed to look like
I double click on bat
And then script
inits ssh connect
writes password
gives the user a terminal with a ready ssh connection.
That is, it mimics the following
Problems
How to wait ssh password request? All commands executes immediately.
(additional) can I write it in .sh script, run script, execute all in "start" terminal (from which I run .sh script) and then pass ssh control to invoked terminal?
It's best if someone writes a ready-made script
Automatically enter SSH password with script
Answers:
Direct answer - use expects. But sshpass is better. Also RSA-key can be used.
Can`t tell anything.
Can be done without any 3rd party tools like this:
$env:TMPPW=Get-Content -Path 'secure_file.txt' ; $un='MyUserName'
$j=Start-Job -ScriptBlock{Start-Sleep -Seconds 1
(New-Object -ComObject wscript.shell).SendKeys("$env:TMPPW{ENTER}")}
& ssh.exe -q -4 -l $un 127.0.0.1 'whoami'
$env:TMPPW=([guid]::NewGuid()).Guid ; $env:TMPPW=$null
I am developing a script which uses ssh to connect to a windows host, run a powershell command, and parse the output. While I can connect to the host and run the command, powershell will not exit and return control back to the local script until I press the enter key.
At the moment, the specific command being run is ssh HOSTNAME 'echo $(hostname)' and the ssh server is configured to pass remote execution requests to powershell -noninteractive -command CMD, where HOSTNAME is the name of the windows host and CMD is the remote command to be run (in this case echo $(hostname)).
The end goal is to have the script which is calling remote powershell commands to run completely noninteractively, but this is currently impossible as the powershell command will not run noninteractively.
How do I get powershell to run remote commands noninteractively?
I've resolved the issue. While I haven't determined what was causing the issue, I can at least overcome the issue at hand by redirecting stdin to /dev/null on the side that initiates the ssh connection.
$ ssh HOSTNAME "CMD" </dev/null
This solution doesn't involve powershell at all, but rather treats the symptoms from the other side of the connection.
i have installed fresshd in one of my windows server.now i am connect to the system through putty. It is working fine.
my issue us when i am running from command line
PuTTY.lnk -ssh -2 -P 22 username#XXX -pw pswd -m command.txt
commands given in the command.txt files are not executed it just open the putty console and it is closing.
when Running from Jenkins also same issue.
I am not sure if you are connecting to Windows from a Linux machine, or to Linux from a Windows machine. Or Windows to Windows?
PuTTY.lnk is not an executable. If you try to run that, it should produce an error 'PuTTY.lnk' is not recognized as an internal or external command. I am assuming you are running the command from a Windows machine, since you are referring to windows shortcut file (.lnk)
You need to use PuTTY.exe + the rest of your command line. Please note that unless it is in your $PATH settings, you would have to provide a full path to the .exe, for example C:\LocationOfPuttyInstall\putty.exe -ssh -2 -P 22 username#XXX -pw pswd -m command.txt. For the sake of preventing any other problem, you should also specify a correct full path to the command.txt file.
If you are not sure where your Putty is installed, on the Windows machine, do the following:
Right click your PuTTY shortcut (the PuTTY.lnk file)
Look under "Target"
That would list your full path to PuTTY.exe executable.
This should resolve your problem.
p.s.
Usually Putty is used to connect from a Windows machine to a Linux machine. From your question, it almost looks like you are trying to connect from a Windows machine to another Windows machine.
You should use PsExec windows tool for such purposes:
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
I am trying to create a word document on a remote windows machine. What I am trying is to telnet to the remote windows machine and run a perl script that creates word document through Win32::OLE. But it doesn't seem to work. Is this possible? Because my script has {visible} set to 1 but will that telnet session have access to instances of word application? Atleast I tried it didn't work.
Telnet may not be the best tool to accomplish this, I'm not sure what kind of permissions it has. I recommend using PsExec, which allows remote command execution on windows servers. If it works locally, it will work using PsExec.
For example:
PsExec.exe \\remotecomputer -u userName -p Password Perl C:\path\to\file\file.pl
You can use the -s flag to run as system account, and the -i flag to run it interactively on the desktop. Without the -i flag, it will run in the console session.
We have a windows Oracle vm installed on our solaris machine which will be launched using Xmanager.
Can some one please help me with the following questions
I can use the folders on solaris from windows VM using "\vboxsrv" but how can i do viceversa
How can i access files on windows vm from solaris machine
And can i update the files on windows vm directly without opening it through xmanager
I found a way to execute a command on virtual machine from Hostmachine. Using this command tool I am accessing files or folders in virtual machine
The command line tool is VBoxManage - This has lot of parameters using we can do any thing on virtual machine from VM starting to shutdown
/opt/VirtualBox > VBoxManage Startvm "windows"
/opt/VirtualBox > VBoxManage guestcontrol "windows" execute --image "cmd.exe" --username root --password 12345 --wait-exit --wait-stdout -- -l /usr