Show More
@@ -22,7 +22,6 b' from subprocess import Popen, PIPE' | |||||
22 | import tempfile |
|
22 | import tempfile | |
23 |
|
23 | |||
24 | import zmq |
|
24 | import zmq | |
25 | from zmq.ssh import tunnel |
|
|||
26 |
|
25 | |||
27 | # IPython imports |
|
26 | # IPython imports | |
28 | from IPython.config import LoggingConfigurable |
|
27 | from IPython.config import LoggingConfigurable | |
@@ -342,6 +341,7 b' def tunnel_to_kernel(connection_info, sshserver, sshkey=None):' | |||||
342 | (shell, iopub, stdin, hb) : ints |
|
341 | (shell, iopub, stdin, hb) : ints | |
343 | The four ports on localhost that have been forwarded to the kernel. |
|
342 | The four ports on localhost that have been forwarded to the kernel. | |
344 | """ |
|
343 | """ | |
|
344 | from zmq.ssh import tunnel | |||
345 | if isinstance(connection_info, string_types): |
|
345 | if isinstance(connection_info, string_types): | |
346 | # it's a path, unpack it |
|
346 | # it's a path, unpack it | |
347 | with open(connection_info) as f: |
|
347 | with open(connection_info) as f: |
@@ -18,7 +18,6 b' from pprint import pprint' | |||||
18 | pjoin = os.path.join |
|
18 | pjoin = os.path.join | |
19 |
|
19 | |||
20 | import zmq |
|
20 | import zmq | |
21 | from zmq.ssh import tunnel |
|
|||
22 |
|
21 | |||
23 | from IPython.config.configurable import MultipleInstanceError |
|
22 | from IPython.config.configurable import MultipleInstanceError | |
24 | from IPython.core.application import BaseIPythonApplication |
|
23 | from IPython.core.application import BaseIPythonApplication | |
@@ -443,6 +442,7 b' class Client(HasTraits):' | |||||
443 | # default to ssh via localhost |
|
442 | # default to ssh via localhost | |
444 | sshserver = addr |
|
443 | sshserver = addr | |
445 | if self._ssh and password is None: |
|
444 | if self._ssh and password is None: | |
|
445 | from zmq.ssh import tunnel | |||
446 | if tunnel.try_passwordless_ssh(sshserver, sshkey, paramiko): |
|
446 | if tunnel.try_passwordless_ssh(sshserver, sshkey, paramiko): | |
447 | password=False |
|
447 | password=False | |
448 | else: |
|
448 | else: | |
@@ -467,6 +467,7 b' class Client(HasTraits):' | |||||
467 | self._query_socket = self._context.socket(zmq.DEALER) |
|
467 | self._query_socket = self._context.socket(zmq.DEALER) | |
468 |
|
468 | |||
469 | if self._ssh: |
|
469 | if self._ssh: | |
|
470 | from zmq.ssh import tunnel | |||
470 | tunnel.tunnel_connection(self._query_socket, cfg['registration'], sshserver, **ssh_kwargs) |
|
471 | tunnel.tunnel_connection(self._query_socket, cfg['registration'], sshserver, **ssh_kwargs) | |
471 | else: |
|
472 | else: | |
472 | self._query_socket.connect(cfg['registration']) |
|
473 | self._query_socket.connect(cfg['registration']) | |
@@ -589,6 +590,7 b' class Client(HasTraits):' | |||||
589 |
|
590 | |||
590 | def connect_socket(s, url): |
|
591 | def connect_socket(s, url): | |
591 | if self._ssh: |
|
592 | if self._ssh: | |
|
593 | from zmq.ssh import tunnel | |||
592 | return tunnel.tunnel_connection(s, url, sshserver, **ssh_kwargs) |
|
594 | return tunnel.tunnel_connection(s, url, sshserver, **ssh_kwargs) | |
593 | else: |
|
595 | else: | |
594 | return s.connect(url) |
|
596 | return s.connect(url) |
@@ -14,11 +14,10 b' from getpass import getpass' | |||||
14 |
|
14 | |||
15 | import zmq |
|
15 | import zmq | |
16 | from zmq.eventloop import ioloop, zmqstream |
|
16 | from zmq.eventloop import ioloop, zmqstream | |
17 | from zmq.ssh import tunnel |
|
|||
18 |
|
17 | |||
19 | from IPython.utils.localinterfaces import localhost |
|
18 | from IPython.utils.localinterfaces import localhost | |
20 | from IPython.utils.traitlets import ( |
|
19 | from IPython.utils.traitlets import ( | |
21 |
Instance, Dict, Integer, Type, Float, |
|
20 | Instance, Dict, Integer, Type, Float, Unicode, CBytes, Bool | |
22 | ) |
|
21 | ) | |
23 | from IPython.utils.py3compat import cast_bytes |
|
22 | from IPython.utils.py3compat import cast_bytes | |
24 |
|
23 | |||
@@ -58,6 +57,11 b' class EngineFactory(RegistrationFactory):' | |||||
58 | help="""The SSH private key file to use when tunneling connections to the Controller.""") |
|
57 | help="""The SSH private key file to use when tunneling connections to the Controller.""") | |
59 | paramiko=Bool(sys.platform == 'win32', config=True, |
|
58 | paramiko=Bool(sys.platform == 'win32', config=True, | |
60 | help="""Whether to use paramiko instead of openssh for tunnels.""") |
|
59 | help="""Whether to use paramiko instead of openssh for tunnels.""") | |
|
60 | ||||
|
61 | @property | |||
|
62 | def tunnel_mod(self): | |||
|
63 | from zmq.ssh import tunnel | |||
|
64 | return tunnel | |||
61 |
|
65 | |||
62 |
|
66 | |||
63 | # not configurable: |
|
67 | # not configurable: | |
@@ -97,7 +101,7 b' class EngineFactory(RegistrationFactory):' | |||||
97 | self.sshserver = self.url.split('://')[1].split(':')[0] |
|
101 | self.sshserver = self.url.split('://')[1].split(':')[0] | |
98 |
|
102 | |||
99 | if self.using_ssh: |
|
103 | if self.using_ssh: | |
100 | if tunnel.try_passwordless_ssh(self.sshserver, self.sshkey, self.paramiko): |
|
104 | if self.tunnel_mod.try_passwordless_ssh(self.sshserver, self.sshkey, self.paramiko): | |
101 | password=False |
|
105 | password=False | |
102 | else: |
|
106 | else: | |
103 | password = getpass("SSH Password for %s: "%self.sshserver) |
|
107 | password = getpass("SSH Password for %s: "%self.sshserver) | |
@@ -108,7 +112,7 b' class EngineFactory(RegistrationFactory):' | |||||
108 | url = disambiguate_url(url, self.location) |
|
112 | url = disambiguate_url(url, self.location) | |
109 | if self.using_ssh: |
|
113 | if self.using_ssh: | |
110 | self.log.debug("Tunneling connection to %s via %s", url, self.sshserver) |
|
114 | self.log.debug("Tunneling connection to %s via %s", url, self.sshserver) | |
111 | return tunnel.tunnel_connection(s, url, self.sshserver, |
|
115 | return self.tunnel_mod.tunnel_connection(s, url, self.sshserver, | |
112 | keyfile=self.sshkey, paramiko=self.paramiko, |
|
116 | keyfile=self.sshkey, paramiko=self.paramiko, | |
113 | password=password, |
|
117 | password=password, | |
114 | ) |
|
118 | ) | |
@@ -120,7 +124,7 b' class EngineFactory(RegistrationFactory):' | |||||
120 | url = disambiguate_url(url, self.location) |
|
124 | url = disambiguate_url(url, self.location) | |
121 | if self.using_ssh: |
|
125 | if self.using_ssh: | |
122 | self.log.debug("Tunneling connection to %s via %s", url, self.sshserver) |
|
126 | self.log.debug("Tunneling connection to %s via %s", url, self.sshserver) | |
123 | url,tunnelobj = tunnel.open_tunnel(url, self.sshserver, |
|
127 | url, tunnelobj = self.tunnel_mod.open_tunnel(url, self.sshserver, | |
124 | keyfile=self.sshkey, paramiko=self.paramiko, |
|
128 | keyfile=self.sshkey, paramiko=self.paramiko, | |
125 | password=password, |
|
129 | password=password, | |
126 | ) |
|
130 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now