使用Python在LAN桌面中打开应用程序
昨天,我可以使用以下脚本从Windows PC成功连接到Unix服务器:使用Python在LAN桌面中打开应用程序,python,python-2.7,unix,lan,Python,Python 2.7,Unix,Lan,昨天,我可以使用以下脚本从Windows PC成功连接到Unix服务器: **import paramiko ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect('punltc02.force.com',username = 'amkar',password = 'new') stdin,stdout,stderr = ssh.exec_command("
**import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('punltc02.force.com',username = 'amkar',password = 'new')
stdin,stdout,stderr = ssh.exec_command("pwd") (it works !!)
>>> stdout.readlines()
[u'/home/amkar\n'
今天,我尝试做同样的事情,但我尝试从笔记本电脑连接到Windows桌面,而不是Unix服务器。我需要连接到桌面并开始使用Python运行应用程序。我得到以下错误:
*`enter code here`*>>> ssh.connect('135.24.237.144',username =
'administrator',password = 'force')
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\lib\site-packages\paramiko\client.py", line 251, in
connect
retry_on_signal(lambda: sock.connect(addr))
File "C:\Python27\lib\site-packages\paramiko\util.py", line 270, in
retry_on_signal
return function()
File "C:\Python27\lib\site-packages\paramiko\client.py", line 251, in
<lambda>
retry_on_signal(lambda: sock.connect(addr))
File "C:\Python27\lib\socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
error: [Errno 10061] No connection could be made because the target
machine actively refused it**
我怀疑我是否也需要在局域网桌面上安装OpenSSH。或者,还有其他方法可以做到这一点。请帮忙
感谢和问候,
Amitra您必须在LAN桌面上安装OpenSSH 另外,如果已经安装了OpenSSH,请尝试禁用防火墙。Ping远程计算机以检查您的计算机与远程计算机之间是否存在连接 您可以使用来执行远程应用程序。您可以使用以下选项: 另一种可能性是。可能是这样吗?
桌面上有SSH服务器吗?我需要检查一下。刚才我发现我可以:ping桌面,也可以做MSTSC。但我无法通过WinSCP连接。Ping告诉您,一台计算机可以连接到另一台计算机。如果没有运行SSH服务器,而您试图连接SSH、SCP或SFTP,则您的数据帧将到达该计算机,并且将被拒绝,因为该计算机上没有运行任何软件来理解和处理它。@user3565150正如Bartosz所述,您需要在LAN计算机上运行SSH服务。因为windows机器默认情况下没有任何SSH服务运行。您必须安装一些SSH服务。谢谢!!我将安装SSH并重试
import paramiko
sh = paramiko.SSHClient()
ssh.connect(server, username=username, password=password)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(cmd_to_execute_on_remote_machine)
import paramiko
import threading
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('10.0.2.15', username='root', password='toor')
chan = ssh.get_transport().open_session()
chan.send('Hey i am connected :) ')
print chan.recv(1024)
client.close