philippe
philippe

Reputation: 3189

paramiko sftp.get

I am trying to use paramiko to download a file via SFTP. I create the SFTP object like this:

transport = paramiko.Transport((sftp_server, sftp_port))
transport.connect(username = sftp_login, password = sftp_password)
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.get("file_name", '.', None)

and, I get the exception:

Exception python : Folder not found: \\$IP_ADDRESS\folder_1/folder_2\file_name.

I'm running paramiko to connect to a client chrooted SFTP. The file, 'file_name', is located at the root of my client's chroot.

I will provide any necessary information.

Upvotes: 2

Views: 9905

Answers (1)

jcollado
jcollado

Reputation: 40424

The following code worked for me in Ubuntu 11.10:

sftp.get("file_name", "file_name")

I just made a couple of changes that shouldn't affect to your problem:

  • localpath: Used full path to the local file name instead of just '.' (directories aren't allowed)
  • callback: Removed it since None is already the default value and that's not really needed

Since I'm not getting the same error you're getting regarding the remotepath parameter, I guess you might be using a different sftp server that has a different behaviour.

My advice would be to:

  • Verify with another client, for example the sftp command, that the file you're looking for is really where you are trying to get it.
  • Use sftp.chdir just to make sure that the default directory being used is the one you expect.

I hope this helps.

Upvotes: 6

Related Questions