![]() |
Paramiko SSH "put", destination name - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Paramiko SSH "put", destination name (/thread-2524.html) |
Paramiko SSH "put", destination name - j.crater - Mar-23-2017 Hello all, I am having difficulties understanding paramiko's behaviour, when it comes to sending files over SSH. I have this function: def SSH_send_file(file, host, username, password, path): s = paramiko.SSHClient() s.set_missing_host_key_policy(paramiko.AutoAddPolicy()) s.connect(host, 22, username, password) sftp = s.open_sftp() sftp.put(file, path) s.close()For example, you would call it like: SSH_send_file("file_to_send.txt", "10.20.30.40", "user", "secret", "/tmp") Until now, it worked fine using it like in the example above. But now (in same program) there was an occassion when this error happened: After some Googling I found that solution is to pass complete destination name to function, which means the file name included, like this:SSH_send_file("file_to_send.txt", "10.20.30.40", "user", "secret", "/tmp/file_to_send.txt") Why did this function "change behaviour", so I had to use it differently in one case, as opposed to previous uses? Can I avoid/predict it in future? Thank you! JC RE: Paramiko SSH "put", destination name - buran - Mar-23-2017 well, no experience with paramiko, but only by reading the docs, I would say always include the filename to avoid errors: Quote:remotepath (str) – the destination path on the SFTP server. Note that the filename should be included. Only specifying a directory may result in an error. I would say you were just lucky not getting error on previous occasion RE: Paramiko SSH "put", destination name - j.crater - Mar-23-2017 Alright, behaviour I noticed reflects your quote from the docs. Perhaps I was only lucky so far to not have this error appear. Thank you! |