code: def tunnel_to_kernel(self, connection_info, hostname, sshkey=None,
                           password=None, timeout=10):
          
          lports = zmqtunnel.select_random_ports(4)
          rports = (connection_info['shell_port'], connection_info['iopub_port'],
                    connection_info['stdin_port'], connection_info['hb_port'])
          remote_ip = connection_info['ip']
          for lp, rp in zip(lports, rports):
              self.ssh_tunnel(lp, rp, hostname, remote_ip, sshkey, password,
                              timeout)
          return tuple(lports)
docs: Tunnel connections to a kernel via ssh.
  
          Remote ports are specified in the connection info ci.