Я хочу перенести файл на ssh-сервер dropbear с paramiko. Я использую этот файл (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
и еще один небольшой файл для запроса (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()
Когда я запускаю ssh_own.py, я получаю эту ошибку:
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
Кто-нибудь знает, возможно ли сделать передачу файлов на сервер dropbear от paramiko? Или это просто не совместимо? Я также проверил это с другой машиной Ubuntu, работающей с openssh, и там она работала нормально.