Skip to content

Ansible: p must be exactly 1024, 2048, or 3072 bits long  #909

Closed

Description

@andig

Running ansible 2.2, I'm unable to connect to any of my raspberry pi hosts from OSX. Connection via ssh is fine:

➜  vz git:(entity-init) ✗ ansible keller -m shell -a "echo foo"

paramiko: The authenticity of host '192.168.0.48' can't be established.
The ssh-rsa key fingerprint is xxxxx.
Are you sure you want to continue connecting (yes/no)?
yes
No handlers could be found for logger "paramiko.transport"
keller | UNREACHABLE! => {
    "changed": false,
    "msg": "p must be exactly 1024, 2048, or 3072 bits long",
    "unreachable": true
}

known_hosts shows all keys as ecdsa-sha2-nistp256.

I have no clue what I'm doing wrong?

Activity

  1. andig commented on Feb 23, 2017

    @andig
    Author

    Might this be related to #899? Not being a crypto guy- is there anything I could do as workaround?

  2. ploxiln commented on Feb 23, 2017

    @ploxiln
    Contributor

    #899 is why is "authenticity ... can't be established" even though the ecdsa host key is in known_hosts. but it doesn't explain "p must be exactly ...". Are you by any chance using a 768 bit or 4096 bit rsa authentication key (for password-less ssh)?

  3. andig commented on Feb 23, 2017

    @andig
    Author

    Are you by any chance using a 768 bit or 4096 bit rsa authentication key (for password-less ssh)?

    I'm guessing how to answer:

    ➜  vz git:(entity-init) ✗ ssh-keygen -l -f ~/.ssh/id_dsa
    1023 SHA256:FQDqH08X0duYLw8swg0gAd+sa8rAeOHJKrsxeKLwMf0 no comment (DSA)
    

    Don't ask me why/where those 1023 bits are coming from...

  4. ploxiln commented on Feb 23, 2017

    @ploxiln
    Contributor

    Yup, 1023-bit dsa keys exist, but they're not common, so not everything supports them. Your problem is from cryptography (dependency of paramiko 2.x):
    https://github.com/pyca/cryptography/blob/master/src/cryptography/hazmat/primitives/asymmetric/dsa.py#L132

    I suggest you switch to an RSA-2048 key (or RSA-3072).

  5. andig commented on Feb 23, 2017

    @andig
    Author

    Thanks for letting me know- will make the switch then 👍🏻

  6. davehodg commented on Apr 2, 2020

    @davehodg

    OK, so how do I set q?

    I've got ansible failing to connect to a server with:

    "msg": "q must be exactly 160, 224, or 256 bits long",

  7. ploxiln commented on Apr 2, 2020

    @ploxiln
    Contributor

    You would have to generate a new ssh key. It's unlikely that you have a valid ssh key which has this problem; it's more likely that your ssh key is being misinterpreted as the wrong type of key (and then the bytes in the key don't make sense). This patch for paramiko may fix it: #1606

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions