简体   繁体   English

Paramiko:尝试在远程服务器上执行 python 时抛出错误

[英]Paramiko : Throwing error when trying to execute python on remote server

I have a program to execute python on a remote server using Paramiko.我有一个程序可以使用 Paramiko 在远程服务器上执行 python。 So it is just that the script to call python is located in one remote server and the script caling is located on another.所以只是调用 python 的脚本位于一台远程服务器上,而脚本调用位于另一台服务器上。

So i thought of using Paramiko.所以我想到了使用 Paramiko。 But it is throwing me error.但这让我犯了错误。 tried to correct error using different methods obtained from stack but in vain.尝试使用从堆栈中获得的不同方法来纠正错误,但徒劳无功。 Can anyone kindy help.任何人都可以帮忙。

import paramiko 
import sys
import os 


host = "powe76nk.dfrlpw.com"
port = 8015
username = "tre@dfrlpw"
password = "abcd"

command = "D:\***\FlaskTest\Callfunction.py"

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, port, username, password)


stdin, stdout, stderr = ssh.exec_command(command)
lines = stdout.readlines()
print(lines) 

and it is throwing me error它给我带来了错误

D:\Programs\FlaskAPICallTest\CallingPythonFile>python testingserver.py
Traceback (most recent call last):
  File "testingserver.py", line 15, in <module>
    ssh.connect(host, port, username, password)
  File "C:\Users\fmxdev\AppData\Local\Programs\Python\Python38\lib\site-packages
\paramiko\client.py", line 368, in connect
    raise NoValidConnectionsError(errors)
paramiko.ssh_exception.NoValidConnectionsError: [Errno None] Unable to connect t
o port 8015 on *****

was not able to solve this issue and is checking this for the last 2 days.无法解决此问题,并在过去 2 天检查此问题。 Is there any alternate for this有什么替代品吗

Your username should be tre and not tre@dfrlpw.您的用户名应该是 tre 而不是 tre@dfrlpw。

Also can you manually ssh into the server using ssh command or putty?您还可以使用 ssh 命令或腻子手动将 ssh 插入服务器吗?

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

相关问题 尝试解压缩远程文件时,Python 2.7 fabric / paramiko EOF - Python 2.7 fabric/paramiko EOF when trying to untar a remote file Python:尝试通过SSH执行命令时,Paramiko挂起 - Python: Paramiko hangs when trying to execute commands over SSH 使用Python和paramiko以root身份执行远程命令 - Execute remote commands as root using Python and paramiko 尝试从 SFTP 服务器传输文件时出现 Python Paramiko UTF-8 错误 - Python Paramiko UTF-8 error when trying to stream file from SFTP server Python Paramiko,尝试连接时关闭属性错误“ Nonetype” - Python Paramiko, Attribute Error 'Nonetype' on close when trying to connect 尝试使用 Python Paramiko 建立 SSH 连接时出现“getaddrinfo”错误 - "getaddrinfo" error when trying to establish an SSH connection using Python Paramiko 使用非默认 shell 和 Python Paramiko 在远程服务器上执行本地脚本 - Execute local script on remote server using non-default shell with Python Paramiko 在远程机器上使用 Paramiko 通过 sshClient() 执行本地 python 脚本 - execute local python script over sshClient() with Paramiko in remote machine Python Paramiko,PermissionError:[Errno 13]从远程服务器获取文件时权限被拒绝 - Python Paramiko, PermissionError: [Errno 13] Permission denied when get files from remote server Paramiko 和“远程蟒蛇” - Paramiko and “remote python”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM