1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > python连接windows远程桌面 如何使用Paramiko Python在windows机器之间建立远程桌面连接...

python连接windows远程桌面 如何使用Paramiko Python在windows机器之间建立远程桌面连接...

时间:2023-05-08 07:20:02

相关推荐

python连接windows远程桌面 如何使用Paramiko Python在windows机器之间建立远程桌面连接...

我正在尝试建立从windows计算机到其他windows计算机的远程桌面连接,并尝试了以下方案-import paramiko

ssh = paramiko.SSHClient()

ssh.load_system_host_keys()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect('IP',port = 3389, username='un',password='pwd')

print ("Connected to %s" % 'IP')

stdin, stdout, stderr = ssh.exec_command('ls -1 /root|head -n 5')

print ("STDOUT:\n%s\n\nSTDERR:\n%s\n" %( stdout.read(), stderr.read() ))

在运行上述代码时,我观察到下面的错误消息paramiko.ssh_exception.SSHException: Error reading SSH protocol banner[WinError 10054] An existing connection was forcibly closed by the remote host

我看了一些论坛,了解到对于windows来说,3389是远程桌面连接的端口,因此在代码中使用3389作为端口。在

我还使用了port=22,运行了代码并观察到这个异常:paramiko.ssh_exception.NoValidConnectionsError: [Errno None] Unable to connect to port 22 on IP

这里所述的过程使远程桌面连接。但无法建立连接。在

版本:帕拉米科:2.4.0

python:3.6.4

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。