Windows Server 2019 - Running GUI Application through OpenSSH protocol - user-interface

I need to run remotely GUI Desktop App when connected through SSH.
Is this even achievable? When I try to run app(any GUI) it just hangs there and does nothing.
I need to explicitly make this work with SSH.

For anyone wondering how to run GUI applications using psexec, this is the solution:
psexec64 is located in C:\Windows
psexec64 -accepteula -nobanner \\SERVER.company.co -u DOMAIN\user -p password -h -i 2 C:\\Windows\notepad.exe
Note: You can run any exe on the server, as well as you can run locally,
also if you need to run it from linux here is solution:
First install winexe: https://sourceforge.net/projects/winexe/ - google for installing from cli
winexe -U DOMAIN/user%password //SERVER.company.co "psexec64 -u DOMAIN\user-p password -accepteula -nobanner -h -i 2 C:\Windows\notepad.exe"
Hopefully this will help someone

Related

How to use PGPASS file in Powershell to avoid password prompt?

I had to automate my postgre database backup. As instructed by my software vendor I am trying to use pg_dump.exe (see below) file to take a backup but that prompts me for password.
.\pg_dump.exe -h localhost -p 4432 -U postgres -v -b -F t -f "C:\Backup\Backup.tar" Repo
So googled and found that as per "https://www.postgresql.org/docs/9.6/libpq-pgpass.html" I can create a pgpass.conf file within 'C:\Users\User1\AppData\Roaming\postgresql\pgpass.conf" which I did.
Then I tried to pass data of pgpass.conf file to env variable before executing my pg_dump command. But it is not working. Still I am getting prompt to enter password. This is the content of pgpass.conf file: *:*:*:postgres:password
Below is the code I am trying in PowerShell,
$Env:PGPASSFILE="C:\Users\User1\AppData\Roaming\postgresql\pgpass.conf"
cd "C:\Program Files\Qlik\Sense\Repository\PostgreSQL\9.6\bin"
.\pg_dump.exe -h localhost -p 4432 -U postgres -v -b -F t -f "C:\Backup\Backup.tar" Repo
Why am I still being asked for password?
When I type following code $Env:AppData I get following response "C:\Users\User1\AppData\Roaming"
Everywhere there are guidance on how to use it in UNIX or command prompt but not in powershell. Any help is appreciated. Also if you could direct me how to secure this password file then it will be great.
With password prompt I cannot automate it with windows task scheduler.
I suspect you have a suitable solution, however, as a quick (and not secure) workaround via the command prompt, you can use the variable PGPASSWORD to hold the password then run the backup script.
A sample might be something like:
SET PGPASSWORD=password
cd "C:\Program Files\Qlik\Sense\Repository\PostgreSQL\9.6\bin" pg_dump.exe -h localhost -p 4432 -U postgres -b -F t -f "d:\qs_backup\QSR_backup.tar" QSR
Rod
I have yet to get the damned thing to work yet, but I did find this:
-w
--no-password Never issue a password prompt. If the server requires password authentication and a password is not available by other means
such as a .pgpass file, the connection attempt will fail. This option
can be useful in batch jobs and scripts where no user is present to
enter a password.
I don't see a -w parameter in your call to pg_dump
I used pg_hba file to allow connection "trust" this is riskier method but I had to get things done ASAP. Thank you for your time and effort

Winexe command gives returns irrelevant info and doesn't execute

Hey guys I am trying to use winexe and execute interactive gui programs from my linux machine to my windows and this syntax is just giving me the same thing like I write
winexe --help
Why is that so? I read that on this post: How to activate programs on windows from Linux machine
If I use --system and --interactive=1 in my command, I will be able to run gui programs on my target machine
winexe --system -U "work/user%pw043" --interactive=1 //server.company.co --system "C:\Utility\prog.exe"
So, what is the proper syntax to making this work? I googled all over internet and the resources on this topic are really scarce.
I managed to run executables using combination of winexe and psexec64
winexe -U DOMAIN/user%password //SERVER.company.co "psexec64 -u DOMAIN\user -p password -accepteula -nobanner -h -i 2 C:\windows\notepad.exe

How to automate ISO installation (iDrac for DELL server)?

I need to automate ISO installation on Dell server. For such systems we have host itself and another ip for the iDrac management interface.
The flow that I need to automate is:
Connect a USB with ISO DD image to the system
reboot the host (can be done via ssh directly or from iDrac virtual console that connects to the host)
After the reboot, I don't have ssh connection to host but in the KVM (virtual console) I can still see the rebooting process and communicate with it. for example pressing F2 F11 etc.
Change the BIOS setup to start from USB and complete the installation by filling all required parameters.
For that purpose I tried using the pywinauto (we have a RobotFramework + Python2.7), but the problem that I'm facing that the KVM (virtual console) is recognized as one window (with no children or other controls).
So I can type keys like: ENTER SPACE Arrows(Up,Down,Left,Right) TAB F2 F11... but I'm not able to get or read the content of the console shown in the screen, what enforce me to use hardcoded steps and use sleeps between steps.
Something else that I thought that can help is connecting to the iDrac via SSH and with racadm api to try to get that content, but I couldn't find a subcommand that gives such information.
So am out of options, I know about other tool called Sikuli that works with image recognition which I used before to automate iOS and I found the reliability of it hard to trust so am not going to try it again.
Please advise if there is such a tool that can extract that console content.
BTW, the console can be opened with different plug-in types such: Native, Java, Html5 (only in iDrac 8+), even with Html5 the control that contains that console is a <canvas> that I can’t really extract anything from it (beside that I need to cover older versions of iDrac)
I work for Dell. There are a couple options. Simplest is to use remote racadm from your script. You can install racamd on any Windows or Linux machine. You can use racadm to dispaly boot order then change it and boot the host.
http://topics-cdn.dell.com/pdf/idrac7-8-lifecycle-controller-v2.30.30.30_Reference%20Guide4_en-us.pdf
racadm -r <idrac-ip> -u <user> -p <passwd> get BIOS.BiosBootSettings
racadm -r <idrac-ip> -u <user> -p <passwd> set BIOS.BiosBootSettings.HddSeq
racadm -r <idrac-ip> -u <user> -p <passwd> serveraction powerup
Other options are wsman and redfish you can learn about those on the Dell Tech Center wiki http://de.community.dell.com/techcenter/w/wiki
Place the desired ISO on a Windows share
Install racadm tools on your workstation
https://www.dell.com/support/home/us/en/04/drivers/driversdetails?driverid=8gmf6
In command line, give the iDRAC command to mount the shared ISO to the server where you want to install the iso content:
racadm -r remote_machine_iDRAC_IP -u idrac_user -p idrac_password remoteimage -c -u remote_share_user -p remote_share_passwd -l //remote_share_IP/iso/<iso_name>
Change boot order:
racadm -r remote_machine_iDRAC_IP -u idrac_user -p idrac_password remoteimage -c -u remote_share_user -p remote_share_passwd set idrac.ServerBoot.FirstBootDevice VCD-DVD
Use powercycle if machine machine is powered up, or powerup if it is powered down:
racadm -r remote_machine_iDRAC_IP -u idrac_user -p idrac_password remoteimage -c -u remote_share_user -p remote_share_passwd serveraction powercycle/powerup
When you connect to the iDRAC console it should boot (assuming the ISO is a bootable image) to the OS installation screen.
Do the installation and right before restarting it following the OS deployment disconnect the mounted ISO:
racadm -r remote_machine_iDRAC_IP -u idrac_user -p idrac_password remoteimage -d
selecting on f11 boot manager and then click on shot bios menu
and then selected bootable usb. it is doing automatic

cscript prnport.vbs Remote Desktop Connection Error 0x80041001 Generic failure

I'm trying to run the following command on a remote server (Windows Server 2008r2) but it comes up with 0x80041001 Generic failure - I am running CMD in Admin mode and I know the script works as it will run on my local Windows 8 PC.
Any advice would be great!
cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\Prnport.vbs -a -r TEST -h 10.227.190.10 -o raw -n 9100
My account was an Active Directory account. It had to be a local account to work :)

psshutdown fails unless run from admin cmd prompt

Ok here's an interesting problem I've run into. I'm attempting to reboot some computers remotely using psshutdown and getting access denied errors unless I run the cmd from a cmd prompt that was run as admin. I myself am an admin on my machine as well as on the remote computer so my credentials should work just fine.
Example code:
psshutdown /accepteula \\COMPUTER.DOMAIN.COM -u DOMAIN\USER -p Password -r -t 0
Example output:
Could not start PsShutdown service on COMPUTER.DOMAIN.COM:
Access is denied.
However when run from admin cmd window:
COMPUTER.DOMAIN.COM is scheduled to reboot in 00:00:00.
As kludge-y as it seems, is it possible to use psexec to run psshutdown as an elevated user?
After running around in circles with this I ended up using:
runas /netonly /user:DOMAIN\USERNAME "shutdown -m \\XXX.XXX.XXX.XXX -r -f -t 0"
Which isn't ideal but got the job done.
Ok, try this. It will open an external window where you can remotely shutdown computers on your network:
shutdown -i
You can type this straight into the CMD window without needing to create a .bat file.
Hope this helps!

Resources