Python Fabric run command returns “binascii.Error: Incorrect padding”

后端 未结 3 1487
迷失自我
迷失自我 2021-01-16 07:11

I\'m trying to connect to connect to amazon EC2 via fabric using the script below. But I\'m met with a problem that I\'m not sure how to solve it.

import os
         


        
相关标签:
3条回答
  • 2021-01-16 07:18

    Look at your ~/.ssh/known_hosts file. It may contain lines with duplicate entries or be corrupted in some other way.

    0 讨论(0)
  • 2021-01-16 07:29

    I saw some places where Incorrect Padding error was resulted from binascii module and it was mostly when the string you pass has some extraneous white-space characters.

    >>> import binascii
    >>> binascii.a2b_base64('a')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    binascii.Error: Incorrect padding
    

    In your case, it the various properties you set for your env object. Do something like this for your key file location and see if that works.

    filelocation = os.path.join(WORK,'aws/myproject.pem')
    env.key_filename = [filelocation]
    
    0 讨论(0)
  • 2021-01-16 07:30

    I had a similar problem and tracked it down to some corruption in my .ssh/known_hosts file.

    I thus added to my .bashrc

    alias deploy='mv ~/.ssh/known_hosts ~/.ssh/known_hosts.tmp; fab <myfabscript>; mv ~/.ssh/known_hosts.old ~/.ssh/known_hosts'
    

    (obviously putting the right fabric script where <myfabscript> is) and now all works fine when I simply run "deploy"!

    0 讨论(0)
提交回复
热议问题