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

sshtunnel not working. keeps showing ERROR | Password is required for key #272

Open
shamounilyas opened this issue Mar 7, 2023 · 1 comment · May be fixed by #286
Open

sshtunnel not working. keeps showing ERROR | Password is required for key #272

shamounilyas opened this issue Mar 7, 2023 · 1 comment · May be fixed by #286

Comments

@shamounilyas
Copy link

I have been using sshtunnel for a long time to connect to my mysql database on a linode server. Recently it stopped working. It is showing me the following error:

ERROR | Password is required for key

I use the following script to connect to the remote server.

key_file = os.path.join('C:\\Users\\user\\.ssh', 'id_rsa')

server = sshtunnel.SSHTunnelForwarder(
    ('remote_ip_address',22),
    ssh_username="user",
    ssh_pkey= key_file,
    ssh_private_key_password="password",
    remote_bind_address=('127.0.0.1', 3306),
    local_bind_address=('127.0.0.1', 3306)
)

server.start()

I can connect to the server through SSH just fine otherwise - through terminal. Just not happening through sshtunnel module.

@hardyoyo
Copy link

this seems to be caused by this line:
https://github.com/pahaz/sshtunnel/blob/master/sshtunnel.py#L1314

which incorrectly emits an error message, when this message should be classed as a warning.

I have successfully monkey-patched this code to emit a warning, which I can then ignore, in my own code. There are multiple threads about this issue in various forums, and the general advice seems to be "just ignore it, it's not an error, your code will keep working" ... I beg to differ, it literally is an error, and that line is where it's thrown.

I mention this in the hopes that line can be changed to logger.warning ... but in the mean time, if you'd like to keep using this library as-is, you can monkey-patch the read_private_key_file function in sshtunnel.py.

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

Successfully merging a pull request may close this issue.

2 participants