fix(ssh-tunnel): wrap pkey into StringIO buffer before creating the tunnel (#22763)
This commit is contained in:
parent
c58dbf8b9c
commit
c536f713d6
|
|
@ -16,9 +16,11 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
|
from io import StringIO
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
from paramiko import RSAKey
|
||||||
from sshtunnel import open_tunnel, SSHTunnelForwarder
|
from sshtunnel import open_tunnel, SSHTunnelForwarder
|
||||||
|
|
||||||
from superset.databases.utils import make_url_safe
|
from superset.databases.utils import make_url_safe
|
||||||
|
|
@ -59,7 +61,9 @@ class SSHManager:
|
||||||
if ssh_tunnel.password:
|
if ssh_tunnel.password:
|
||||||
params["ssh_password"] = ssh_tunnel.password
|
params["ssh_password"] = ssh_tunnel.password
|
||||||
elif ssh_tunnel.private_key:
|
elif ssh_tunnel.private_key:
|
||||||
params["private_key"] = ssh_tunnel.private_key
|
private_key_file = StringIO(ssh_tunnel.private_key)
|
||||||
|
private_key = RSAKey.from_private_key(private_key_file)
|
||||||
|
params["private_key"] = private_key
|
||||||
params["private_key_password"] = ssh_tunnel.private_key_password
|
params["private_key_password"] = ssh_tunnel.private_key_password
|
||||||
|
|
||||||
return open_tunnel(**params)
|
return open_tunnel(**params)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue