I am attempting to use SSHTunnelForwarder. I receive an error "IP is not a string (NoneType)". If I understand correctly, that means the host variable I'm passing is of type NoneType and needs to be String type. Printing out the variables type shows that it is of type string: <class 'str'>.
I've generalized the code in question. See below:
def connectToClient(client):
key, host = getClientInfo(client)
# Both of the below print statements return <class 'str'>
print(type(key))
print(type(host))
try:
with SSHTunnelForwarder(
ssh_username = "username",
ssh_private_key = key,
remote_bind_address = (host, 22)) as server:
# Do stuff here
except Exception as e:
# Handle exception
Stack Trace (edited to hide file system info and .py file name. Also testing with 0.0.0.0):
Traceback (most recent call last):
File "/path/to/file/myPythonFile.py", line 83, in connectToClient
remote_bind_address = ('0.0.0.0', 22)) as server:
File "/path/to/file/lib/python3.6/site-packages/sshtunnel.py", line 908, in __init__
check_host(self.ssh_host)
File "/path/to/file/lib/python3.6/site-packages/sshtunnel.py", line 79, in check_host
type(host).__name__
AssertionError: IP is not a string (NoneType)
I'd like to point out that even if I replace the host variable with a string holding an IP (i.e. '127.0.0.1'), I still receive the same error.
Perhaps I'm making a simple mistake. Any ideas?
Edit: Fix formatting and add stack trace