ParallelSSH / ssh2-python

Python bindings for libssh2 C library.
https://parallel-ssh.org
GNU Lesser General Public License v2.1
228 stars 72 forks source link

Properly fix Session.userauth_keyboardinteractive #121

Closed Red-M closed 3 years ago

Red-M commented 3 years ago

Because it cannot take a string as the password, it needs a callback function.

This fixes #58.

pkittenis commented 3 years ago

Thanks for contribution. Comments inline.

Red-M commented 3 years ago

Apologies, I missed a few pieces porting this back from my fork.

pkittenis commented 3 years ago

Needs more test coverage.

Suggest to add to test_session.py:

    def test_failed_keyboard_interactive_auth_valid_user(self):
        self.assertRaises(
            AuthenticationError,
            self.session.userauth_keyboardinteractive, self.user, 'FAKE PASSWORD'
        )

    def test_failed_keyboard_interactive_auth_valid_user_no_pass(self):
        self.assertRaises(
            AuthenticationError,
            self.session.userauth_keyboardinteractive, self.user, ''
        )

Valid user wrong password should be enough to test all the written code. Authentication should still fail as we don't know the password.

pkittenis commented 3 years ago

Have made changes to this at #123

The callback was segfaulting - tests were not actually run as keyboard interactive auth was not allowed in the embedded server. Some other issues also resolved.

Would suggest getting tests running locally first before a PR - pytest tests works. Have also updated contributing guide.