[英]How can I remotely unlock a Windows workstation using SSH?
I'm running an OpenSSH server on a Windows 10 workstation, which I'm connecting to from Linux and using to run PowerShell scripts on the host machine, querying information about things like running processes and administrating the system.我正在Windows 10工作站上运行OpenSSH服务器,我从Linux连接到该工作站并用于运行 PowerShell 脚本,例如在主机上运行进程管理员和查询系统信息。
I know that some actions such as remotely launching a gui application visible to users on the host machine are limited as a result of OpenSSH's sshd
service existing in session 0 isolation.我知道由于session 0 隔离中存在 OpenSSH 的
sshd
服务,某些操作(例如远程启动主机上用户可见的 gui 应用程序)受到限制。 I've been able to work around this freely by scheduling anything I want to execute as a task with schtasks.exe
and immediately running the task.通过使用
schtasks.exe
将我想要执行的任何任务安排为任务并立即运行该任务,我已经能够自由地解决这个问题。
rundll32.exe user32.dll,LockWorkStation
rundll32.exe user32.dll,LockWorkStation
锁定工作站Get-Process logonui
Get-Process logonui
锁定 I've tried this third-party utility called Logon.exe
, to no avail.我试过这个名为
Logon.exe
的第三方实用程序,但无济于事。 I don't believe it is compatible with Windows 10.我不相信它与 Windows 10 兼容。
I've even tried using SendKeys()
with PowerShell to send the password's keystrokes while on the lockscreen and then press enter, as well as an AutoHotKey script to do the same.我什至尝试使用带有 PowerShell 的
SendKeys()
在锁屏时发送密码击键,然后按 Enter,以及使用 AutoHotKey 脚本来执行相同操作。 While the keystrokes cause the lockscreen to wake up, neither methods seem to be capable of creating any input in the password input field.虽然击键会导致锁屏唤醒,但两种方法似乎都无法在密码输入字段中创建任何输入。
Here is the Microsoft Doc for Ref: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse这是参考的 Microsoft Doc: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
Download下载
Get-WindowsCapability -Online |?获取-WindowsCapability-在线|? Name -like 'OpenSSH*'
名称 - 类似 'OpenSSH*'
Install.安装。 Ensure you install SSH server as that is what allows others to connect to you.
确保安装 SSH 服务器,因为它允许其他人连接到您。
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Configuration.配置。 Notice the inbound traffic rule.
注意入站流量规则。 Super necessary.
超级需要。
Start-Service sshd启动服务 sshd
Set-Service -Name sshd -StartupType 'Automatic'设置服务-名称 sshd -StartupType '自动'
Get-NetFirewallRule -Name ssh获取-NetFirewallRule -Name ssh
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
And finally, here is how you connect最后,这是您的连接方式
ssh username@servername ssh 用户名@服务器名
Enjoy享受
PS. PS。 I tried with the formatting.
我尝试了格式化。 I didn't want bold, it just kept happening captain.
我不想大胆,它只是不断发生队长。 The internet decided it wanted to be bold today...
互联网决定今天要大胆一些……
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.