简体   繁体   English

使用python通过ssh在远程计算机上启动脚本-但是相反吗?

[英]Start a script on a remote machine through ssh with python - but in reverse?

Here's what I need to do: 这是我需要做的:

The user is on a remote machine and connects to a server via ssh. 用户位于远程计算机上,并通过ssh连接到服务器。 He runs a python script on the server. 他在服务器上运行python脚本。 The script running on the server starts a script on the user's remote machine as a subprocess and opens a pipe to it for communication. 在服务器上运行的脚本将作为子进程在用户的远程计算机上启动脚本,并打开到该管道的管道以进行通信。

First, is this at all possible? 首先,这有可能吗?

Second, is this possible in such a way that the user does not need to do anything fancy, like open up a reverse ssh tunnel? 其次,是否可以通过这种方式使用户不需要做任何花哨的事情,例如打开反向ssh隧道? If they do have to open up a reverse ssh tunnel, can I figure out which port they are using? 如果他们确实必须打开反向ssh隧道,我能找出他们正在使用哪个端口吗?

First, is this at all possible? 首先,这有可能吗?

With simple user --SSH--> server - no, its not. 对于简单的用户--SSH->服务器-不,不是。

is this possible in such a way that the user does not need to do anything fancy 这样是否可能使用户不需要做任何花哨的事情

User will have to run sshd on his machine, add a user for your server and somehow let you to connect to it, bypassing NAT if any. 用户必须在其计算机上运行sshd,为服务器添加一个用户,然后以某种方式让您连接到该服务器,绕过NAT(如果有)。 So no, there is no such way with SSH. 所以不,SSH没有这种方法。

I'd go with client-side application. 我将使用客户端应用程序。 Give script to user and let him run the script instead of SSH'ing. 给用户脚本,让他运行脚本而不是SSH'ing。 If you need to communicate with server, you can use something like paramiko on client side to connect to server from script. 如果需要与服务器通信,则可以在客户端使用诸如paramiko之类的东西从脚本连接到服务器。 Then, script can launch other applications on client's computer based on data it receives from server. 然后,脚本可以根据客户端从服务器接收的数据启动客户端计算机上的其他应用程序。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM