3

I’m looking to be able to remotely power on my Windows machine and start a program.

I have WoL (Wake on LAN), and a SSH Server configured so I’m able to remotely turn on the machine and remotely access it.

I’d like to be able to next log in a desktop session on that machine (as it will be on the login screen on boot up). Is this possible?

Just to clarify a couple things:

  1. The SSH session I have is authenticated and “logged in” with my user. Im specifically talking about logging in the machine from that session from the perspective of if someone was physically looking at the monitor output.
  2. I don’t want to remove that login screen from boot up, because most of the time I still want the security of having a login process.
  3. I will eventually want to start a gui application in that desktop, so running a process in the ssh session is not what I’m after.
  4. I also do not want to use something that requires human intervention, I.e. using Windows Remote Desktop and having to log in that way.

Edit: Here’s an example. I want a script I want run from a remote machine, which will turn on the computer (WoL current solution), then open a desktop application like the calculator app.

The script itself does not need to interact with that calculator app, but just needs it to be opened for the desktop session of the target windows machine. I.e after the script has run and a user sits down physically at the target windows machine, the calculator app is open on their desktop.

The solution doesn’t need to be ssh, I just assumed an authenticated ssh session would have been part of a solution. But other methods of remote authentication and sending commands are welcome. Though I am looking at running this script from a Linux machine.

Hope that clarifies what I mean by opening a GUI app remotely, and no human intervention.

Final Edit: Check the final reply to the accepted answer for my final solution.

freebie
  • 33

2 Answers2

0

What you're looking for is a KVM over IP console. It is an external piece of hardware that allows you to issue commands as if you were physically at the computer and also view the screen. As it is external hardware, it does not require the operating system, so you are able to access OS login screens and even the BIOS itself.

They are highly customizable and if you are comfortable with buying one, I'm sure they'd fit your use case.

Now, this doesn't answer the part about using SSH credentials to log-in, but depending on the model you chose, you could very easily write a simple script to allow you to do that.

BRUJOjr
  • 38
0

This solution uses ## Part 1 logic which is run once from a session where you will be launching the RDP from to automate the connection part where no human interaction is needed to launch and sign onto the RDP session after this is saved. You will type in the username, password, and machine name on prompt.

The ## Part 2 logic is the only part really used to automate the launching of the RDP session where human interaction is not needed if the machine name connecting to is the same as the one you specified when you part 2 was run. You'll need to execute this as the same user account/security context and from the same machine which you ran part 1 to embed the credential for subsequent RDP connection automation.

This just means, run the part 1 once with human interaction, then setup automation to run part 2 specifying the machine to connect via RDP so it'll connection automatically.

PowerShell

## Part 1
$User = Read-Host "Enter username (e.g. domain\user1)";
$P = Read-Host "Enter password" -AsSecureString;
$psw = New-Object System.Management.Automation.PSCredential -ArgumentList $User,$P;
$Password = [System.Net.NetworkCredential]::new("",$psw.password).Password;
$MachineName = Read-Host "Enter machine name (or IP address)";
cmdkey /add:$MachineName /user:$User /pass:$Password;

Part 2

mstsc /v:"machine123";

How to delete saved credential from command

#cmdkey /delete:"machine123"

The method above is really just the PowerShell equivalent to saving an RDP credential for usage with mstsc per the GUI option from the Windows Security credential pop-up of checking "Remember Me".

When you check Remember Me using the GUI, the next time you go to connect to the same machine via RDP using mstsc, you can press connect and it'll use the saved credential to login.

enter image description here

enter image description here

Lastly, drop a shortcut of the application which you want to run when the RDP session connects in the C:\Users\User1\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup folder. This will execute the shortcut and run the app when that specific user logs in on that machine. You can also do this a couple other ways with Task Scheduler being one of them with delay run options, etc. if needed.

Supporting Resources