17

I am trying to use Paramiko in Python2 for transferring files through SFTP with a private SSH key but it displays this warning:

/usr/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py:141: 
FutureWarning: CTR mode needs counter parameter, not IV   self._cipher = factory.new(key, *args, **kwargs)

In fact it sends the file to the server but can someone explain me what this warning means?

Here is my code:

t = paramiko.Transport((host, port))
key = paramiko.RSAKey.from_private_key_file("/path/to/key.ssh") 
t.connect(username="username",password=None, pkey=key)

sftp = paramiko.SFTPClient.from_transport(t)
sftp.put(source, destination)

sftp.close()
t.close()
Adrián Kálazi
  • 250
  • 1
  • 2
  • 13

4 Answers4

20

This is most likely a bug in paramiko

You can try to patch paramiko/transport.py with this patch to make the warning go away

See also the discussion here which references the pull request.

hansaplast
  • 11,007
  • 2
  • 61
  • 75
4

This worked for me.

  1. Remove the python-paramiko package installed with apt:

apt remove python-paramiko

  1. Install paramiko via pip that provides a newer obviously fixed version:

apt install duplicity python-pip -y

pip install paramiko

quotesBro
  • 6,030
  • 2
  • 31
  • 41
weefwefwqg3
  • 961
  • 10
  • 23
  • Why would I need to install duplicity? – jreisinger Mar 02 '18 at 07:49
  • @Jreisinger, duplicity is used in combination with paramiko. As you can see here: https://github.com/paramiko/paramiko/search?q=duplicity&type=Issues&utf8=%E2%9C%93, many errors get resolved with a proper duplicity installtion. – weefwefwqg3 Mar 12 '18 at 05:12
3

Updating Crypto package vanishes the "CTR mode needs counter parameter, not IV" warning in my case:

pip install -U Crypto
0

What @hansaplast recommended worked great. In my case, I replace vi to at line 1649 in the following file: /usr/lib/python2.7/dist-packages/paramiko/transport.py

Sunghun Jung
  • 33
  • 1
  • 5