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

Script won't exit after one of the loaded ssh keys fails authentication #77

Closed
michaeldunstan opened this issue Oct 21, 2016 · 2 comments

Comments

@michaeldunstan
Copy link

This is similar to #72. What's different here is that several ssh keys are loaded. The first key used fails authentication. The second key passes. Example script:

import threading
import sshtunnel

with sshtunnel.open_tunnel(
    '<remotehost>',
    debug_level='DEBUG',
    remote_bind_address=('localhost', 5432),
) as server:
    print(server.local_bind_port)

# [t.close() for t in threading.enumerate() if t.__class__.__name__ == "Transport"]

print('FINISH!')

Prints out the following but never exits to the shell:

2016-10-21 11:16:55,045| INF | MainThrea/0981@sshtunnel | 3 keys loaded from agent
2016-10-21 11:16:55,045| INF | MainThrea/0901@sshtunnel | Connecting to gateway: <remotehost>:22 as user 'username'
2016-10-21 11:16:55,045| DEB | MainThrea/0904@sshtunnel | Concurrent connections allowed: True
2016-10-21 11:16:55,045| DEB | MainThrea/1284@sshtunnel | Trying to log in with key: 01234567890123456789012345678901
2016-10-21 11:16:55,133| DEB | MainThrea/1293@sshtunnel | Authentication error
2016-10-21 11:16:55,133| WAR | MainThrea/1333@sshtunnel | Server is not started. Please .start() first!
2016-10-21 11:16:55,133| DEB | MainThrea/1351@sshtunnel | Transport is closed
2016-10-21 11:16:55,134| DEB | MainThrea/1284@sshtunnel | Trying to log in with key: 98765432109876543210987654321098
2016-10-21 11:16:55,222| INF | Srv-37096/1318@sshtunnel | Opening tunnel: 0.0.0.0:37096 <> localhost:5432
37096
2016-10-21 11:16:55,222| INF | MainThrea/1337@sshtunnel | Shutting down tunnel ('0.0.0.0', 37096)
2016-10-21 11:16:55,323| INF | Srv-37096/1324@sshtunnel | Tunnel: 0.0.0.0:37096 <> localhost:5432 released
2016-10-21 11:16:55,442| DEB | MainThrea/1351@sshtunnel | Transport is closed
FINISH!

And similar #72 if the second to last line which explicitly closes the paramiko.Transport threads is uncommented then the script exits correctly.

Using sshtunnel 0.1.1, paramiko 1.17.1

fernandezcuesta added a commit that referenced this issue Oct 25, 2016
* is_active() now a wrapper of paramiko.Transport.is_active()
* Increase version number
@fernandezcuesta
Copy link
Collaborator

Hi, thanks for reporting! Could you please retry by installing from source?

@michaeldunstan
Copy link
Author

Yes. That works for me. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants