Paramiko: “FutureWarning: CTR mode needs counter parameter”

六月ゝ 毕业季﹏ 提交于 2019-12-05 13:45:40

问题


I am trying to use Paramiko in Python2 for transferring files through SFTP with 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()

回答1:


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.




回答2:


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




回答3:


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

pip install -U Crypto


来源:https://stackoverflow.com/questions/42029415/paramiko-futurewarning-ctr-mode-needs-counter-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!