★ wanayoo — archive 1999 https://github.com/ParallelSSH/ssh2-python/issues/86Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh2.session.Session.userauth_publickey_frommemory() - TypeError: object of type 'NoneType' has no len() #86

Closed
PhenomPBG opened this issue Oct 1, 2019 · 13 comments

Comments

@PhenomPBG
Copy link

@PhenomPBG PhenomPBG commented Oct 1, 2019

host = "127.0.0.1"
port = 22
user_name = "user"
privatekey_data = "..."
passphrase = ""

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
session = Session()
session.handshake(s)

session.userauth_publickey_frommemory(user_name, privatekey_data.encode('ascii'), passphrase=passphrase)

Last line from stack trace:

File "ssh2/session.pyx", line 240, in ssh2.session.Session.userauth_publickey_frommemory
TypeError: object of type 'NoneType' has no len()

Seems like the optional argument publickeyfiledata defaults to None, but its len() is always checked anyway.

Tested on both 0.17 and 0.18 with Python 3.7.1 on CentOS 7.

@PhenomPBG
Copy link
Author

@PhenomPBG PhenomPBG commented Oct 2, 2019

Cleaned up the sample code a bit.

@j3pic
Copy link

@j3pic j3pic commented Dec 4, 2019

@PhenomPBG the bug remains. #90 doesn't fix it either. I've made a new PR that should fix it.

@PhenomPBG
Copy link
Author

@PhenomPBG PhenomPBG commented Dec 6, 2019

@PhenomPBG the bug remains. #90 doesn't fix it either. I've made a new PR that should fix it.

Thanks!

@Red-M
Copy link

@Red-M Red-M commented Dec 8, 2019

I'll take a look into why this isn't picked up via the unit tests and correct that, then fix the issue itself.

Red-M added a commit to Red-M/Redlibssh2 that referenced this issue Dec 8, 2019
Add enums to clean up any symbols from libssh2 and make interacting with them much easier to do.
Add additional unit tests for ParallelSSH#86
@Red-M
Copy link

@Red-M Red-M commented Dec 8, 2019

I know this isn't an amazing answer but I can't replicate this issue with #90 using the same arguments passed inside of a unit test.

Sadly this repository is over the limit for git LFS usage so the builds won't work, so I've managed to bypass LFS for now inside the builds.

Travis is returning no errors in the unit tests for this particular issue.

@j3pic I'm happy to take patches on my fork because right now it appears that @pkittenis isn't around.

@j3pic
Copy link

@j3pic j3pic commented Dec 18, 2019

@Red-M Will your fork become the version of ssh2-python that installs from PyPI?

@Red-M
Copy link

@Red-M Red-M commented Dec 18, 2019

I'd hope my fork gets merged into ssh2-python as its all there in #90 to merge back in.
I may need to release all the changes under another pypi package name.

@j3pic
Copy link

@j3pic j3pic commented Dec 18, 2019

There's another problem with my patch: It doesn't compile under Python 3.7 and higher because the C source files were built with the wrong version of Cython (but if I upgrade and generate the C files again, they'll be incompatible with Python 3.6 and below.

@Red-M
Copy link

@Red-M Red-M commented Dec 18, 2019

What version should Cython be?
I still can't replicate the issue under #90 as it has guards in place if the public key isn't provided with the private key.

@Red-M
Copy link

@Red-M Red-M commented Dec 18, 2019

My fork has every version passing the tests plus 3.8, https://travis-ci.com/Red-M/ssh2-python/builds/141552354

@j3pic
Copy link

@j3pic j3pic commented Dec 21, 2019

@Red-M Reading the code for #90 it looks like this bug should be fixed there. I'm not sure why I still saw it when I tested manually. Probably because of the bug in Pip I found that affects the use of Git repos from requirements.txt. There's a nonzero chance I was still running the version of ssh2-python from PyPI.

@basegodfelix
Copy link

@basegodfelix basegodfelix commented Jun 16, 2020

still experiencing this issue.

On a side note, if I use the same key and auth from file, it works. Same error thrown as above poster:

File "ssh2/session.pyx", line 237, in ssh2.session.Session.userauth_publickey_frommemory
TypeError: object of type 'NoneType' has no len()

Private key provided

Red-M added a commit to Red-M/Redlibssh2 that referenced this issue Jun 27, 2020
Add enums to clean up any symbols from libssh2 and make interacting with them much easier to do.
Add additional unit tests for ParallelSSH#86
@kdart
Copy link

@kdart kdart commented Jul 17, 2020

A workaround that seems to work for me is to set the publickeyfiledata to an empty bytestring (b'').

pkittenis added a commit that referenced this issue Aug 13, 2020
pkittenis added a commit that referenced this issue Aug 13, 2020
…sts. Resolves #86. (#104)

Updated changelog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants
You can’t perform that action at this time.