bundles / jupyter_client latest / jupyter_client / ssh / tunnel / openssh_tunnel
function
jupyter_client.ssh.tunnel:openssh_tunnel
Signature
def openssh_tunnel(lport: int, rport: int, server: str, remoteip: str = 127.0.0.1, keyfile: str | None = None, password: str | None | bool = None, timeout: int = 60) → intSummary
Create an ssh tunnel using command-line ssh that connects port lport on this machine to localhost:rport on server. The tunnel will automatically close when not in use, remaining open for a minimum of timeout seconds for an initial connection.
Extended Summary
This creates a tunnel redirecting localhost:lport to remoteip:rport, as seen from server.
keyfile and password may be specified, but ssh config is checked for defaults.
Parameters
lport: intlocal port for connecting to the tunnel from this machine.
rport: intport on the remote machine to connect to.
server: strThe ssh server to connect to. The full ssh server string will be parsed. user@server:port
remoteip: str [Default: 127.0.0.1]The remote ip, specifying the destination of the tunnel. Default is localhost, which means that the tunnel would redirect localhost:lport on this machine to localhost:rport on the server.
keyfile: str; path to public key fileThis specifies a key to be used in ssh login, default None. Regular default ssh keys will be used without specifying this argument.
password: str;Your ssh password to the ssh server. Note that if this is left None, you will be prompted for it if passwordless key based login is unavailable.
timeout: int [default: 60]The time (in seconds) after which no activity will result in the tunnel closing. This prevents orphaned tunnels from running forever.
Aliases
jupyter_client.ssh.openssh_tunnel