EOFError beim Übertragen einer Datei an dropbear mit paramiko

514
StrawHat

Ich möchte eine Datei mit Paramiko auf einen Dropbear-SSH-Server übertragen. Ich verwende diese Datei (ssh_own.py):

#!/usr/bin/python3.6  import paramiko import paramiko  from paramiko import client class ssh: client = None  def __init__(self, address, username, password): print("Connecting to server.") self.client = client.SSHClient() self.client.set_missing_host_key_policy(client.AutoAddPolicy()) self.client.connect(address, username = username, password = password, look_for_keys=False)  def sendCommand(self, command): if(self.client): stdin, stdout, stderr = self.client.exec_command(command)  output = [] while not stdout.channel.exit_status_ready(): portion = stdout.readlines() # print(portion) if len(portion) > 0: output.append(portion) result = self.output_to_string(output) return result else: raise Exception("Connection not opened.")  def output_to_string(self, output): result = "" for line in output: for el in line: # result += str(line, "utf8") result += el return result 

und eine weitere kleine Datei für die Anfrage (test.py):

#!/usr/bin/python3.6  import ssh_own import os  home = os.environ["HOME"]  ssh_client = ssh_own.ssh("ip", "username", "password") ftp_client = ssh_client.client.open_sftp() ftp_client.put("/home/localuser/README.md", "/home/username/README.md") ftp_client.close() 

Beim Ausführen von ssh_own.py erhalte ich diese Fehlermeldung:

Connecting to server. Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/paramiko/sftp_client.py", line 103, in __init__ server_version = self._send_version() File "/usr/local/lib/python3.6/dist-packages/paramiko/sftp.py", line 107, in _send_version t, data = self._read_packet() File "/usr/local/lib/python3.6/dist-packages/paramiko/sftp.py", line 174, in _read_packet x = self._read_all(4) File "/usr/local/lib/python3.6/dist-packages/paramiko/sftp.py", line 161, in _read_all raise EOFError() EOFError  During handling of the above exception, another exception occurred:  Traceback (most recent call last): File "./test.py", line 13, in <module> ftp_client = ssh_client.client.open_sftp() File "/usr/local/lib/python3.6/dist-packages/paramiko/client.py", line 521, in open_sftp return self._transport.open_sftp_client() File "/usr/local/lib/python3.6/dist-packages/paramiko/transport.py", line 980, in open_sftp_client return SFTPClient.from_transport(self) File "/usr/local/lib/python3.6/dist-packages/paramiko/sftp_client.py", line 140, in from_transport return cls(chan) File "/usr/local/lib/python3.6/dist-packages/paramiko/sftp_client.py", line 105, in __init__ raise SSHException('EOF during negotiation') paramiko.ssh_exception.SSHException: EOF during negotiation 

Weiß jemand, ob es möglich ist, von paramiko einen Dateitransfer zu einem Dropbear-Server durchzuführen? Oder ist es einfach nicht kompatibel? Ich habe dies auch mit einer anderen Ubuntu-Maschine getestet, auf der openssh läuft, und dort hat es gut funktioniert.

0
Möglicherweise verwandt: https://stackoverflow.com/questions/38554629/python-pysft-paramiko-eof-during-negotiation-error hoefling vor 5 Jahren 0

1 Antwort auf die Frage

0
StrawHat

Es stellte sich heraus, dass ich stfp installieren musste, da dropbear dies nicht zu haben scheint und paramiko sftp für die Dateiübertragung verwendet. scp hat gut mit dropbear funktioniert, aber das hat mich aus erster Hand verwirrt. Nach der Installation von sftp funktionierten alle Dateiübertragungen mit paramiko einwandfrei.