0
I want to transfer a file to a dropbear ssh server with paramiko. I use this file (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
and another small file to make the request (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()
When I run ssh_own.py, I get this error:
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
Does anyone know whether it is possible to do a file transfer to a dropbear server from paramiko? Or is it just not compatible? I also tested this with another Ubuntu machine running openssh and there it worked fine.
Possibly related: https://stackoverflow.com/questions/38554629/python-pysft-paramiko-eof-during-negotiation-error
– hoefling – 2018-05-19T12:31:19.790