简体   繁体   English

是否可以通过ssh进入Windows(通过cygwin sshd)并在登录的Windows用户桌面上启动程序?

[英]Is it possible to ssh into Windows (through a cygwin sshd) and start a program on a logged in Windows user's desktop?

Is it possible to ssh into Windows (through a cygwin sshd) and start a program on a logged in Windows user's desktop? 是否可以通过ssh进入Windows(通过cygwin sshd)并在登录的Windows用户桌面上启动程序?

Put another way, say a user ABC is logged in on windows and a remote user logs in with ABC's login/password over ssh, can remote ABC pop up an app on the local ABC user's desktop? 换句话说,用户ABC登录Windows并且远程用户使用ABC登录/密码通过ssh登录,远程ABC可以在本地ABC用户的桌面上弹出应用吗?

I am asking this on Stackoverflow and not Serverfault because the motivation for doing this is programmatic in nature. 我在Stackoverflow上问这个,而不是Serverfault,因为这样做的动机本质上是程序化的。 The remote call will be coming from a Linux box so while it may be possible(?) to do this using WMI or some other approach, ssh seemed like the simplest. 远程调用将来自Linux机器,因此虽然可能(?)使用WMI或其他方法来执行此操作,但ssh似乎是最简单的。

Happy to hear simpler/better alternatives though. 很高兴听到更简单/更好的选择。

Thanks! 谢谢!

If your cygwin sshd is running under a privileged account, it can get a handle to the current desktop and put windows on it. 如果您的cygwin sshd在特权帐户下运行,它可以获取当前桌面的句柄并在其上放置窗口。 See the desktop parameter of STARTUPINFO for CreateProcess. 请参阅STARTUPINFO for CreateProcess的桌面参数。

My own solution. 我自己的解决方案 Tested on windows XP (but I think it should run in any windows environment with a little effort). 在Windows XP上测试(但我认为它应该在任何Windows环境中运行一点点努力)。

You need to use the psexec and quser command. 您需要使用psexecquser命令。

First, put psexec and quser in a directory included in the cygwin's PATH environment variable. 首先,将psexecquser放在cygwin的PATH环境变量中包含的目录中。 Just copy these files into the bin directory under cygwin. 只需将这些文件复制到cygwin下的bin目录中即可。

You can find the quser.exe in your %system32%\\dllcache dir. 您可以在%system32%\\ dllcache目录中找到quser.exe But for any reason I can't access to it (or access to the mentioned directory) through cygwin commands (ie ls, cp, etc), so I made a copy using the microsoft's copy command to the cygwin\\bin folder. 但由于任何原因我无法通过cygwin命令(即ls,cp等)访问它(或访问提到的目录),所以我使用microsoft的copy命令复制到cygwin \\ bin文件夹。

Notes : I think it's helpful to have the suite psutils all in the bin folder of cygwin. 注意 :我认为将套件psutils全部放在cygwin的bin文件夹中会很有帮助。 The first time you run either of these utilities will have to accept a license agreement from Microsoft warning, so run psexec from Windows explorer the first time. 第一次运行这些实用程序时,必须接受Microsoft警告的许可协议,因此第一次从Windows资源管理器运行psexec。

Then create these alias in your .bash_profile file: 然后在.bash_profile文件中创建这些别名:

alias winrun='psexec \\\\YOU_USERNAME_HERE -d -i `quser | grep YOU_USERNAME_HERE | grep console | awk "{print \\\$3}"`'
alias explorethis='winrun explorer $(cygpath -w `pwd`)'

Remember that you will need to translate the current directory using cygpath if you need to pass it as argument of a command ("explorethis" is an example of that). 请记住,如果需要将其作为命令的参数传递,则需要使用cygpath转换当前目录(“explorethis”就是一个示例)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Windows 上使用 Cygwin 的 SSH ControlMaster 实际上可能吗? - Is SSH ControlMaster with Cygwin on Windows actually possible? 如何在cygwin中启动Windows GUI程序? - how to start a windows GUI program in cygwin? 我如何才能将ssh放入运行cygwin / sshd的Windows框中,并使最终的终端会话使用cygwin而不是默认的BASH? - How can I ssh into a windows box running cygwin/sshd and have the resulting terminal session use cygwin instead of default BASH? 获取与桌面关联的登录Windows用户名 - Get the logged in Windows user name associated with a desktop 在Windows上通过SSH获取桌面的屏幕截图 - Get a Screenshot of the Desktop through SSH on Windows 如何在 Windows 中通过 Cygwin 安装和运行 Nmap 程序? - How to install and run the Nmap program through Cygwin in Windows? 通过Cygwin通过“ Windows命令”启动Perl脚本 - Start Perl script via “Windows Command” through Cygwin Java作为Windows服务,具有交互式桌面支持和已读当前用户 - Java as windows service with interactive desktop support and read curren logged user 有没有办法截取用户的Windows桌面的截图? - Is there a way to take a screenshot of the user's Windows desktop? 登录用户而不是运行程序C#,Windows的用户 - Getting logged in user not the user running the program C#, Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM