<br><br><div class="gmail_quote">On Sat, Aug 6, 2011 at 09:55, neil rabinowitz <span dir="ltr"><<a href="mailto:neil.rabinowitz@merton.ox.ac.uk" target="_blank">neil.rabinowitz@merton.ox.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm still trying to figure out this local vs remote kernel story. Aside
from my ssh question below, can someone offer an explanation/example of how i
set up and connect to a remote kernel (on linux), even if unsecured? The most I can find is from the ipython_qtconsole_config.py file:<br><br># Set the kernel's IP address [default localhost]. If the IP address is <br>
# something other than localhost, then Consoles on other machines will be able <br># to connect to the Kernel, so be careful! <br># c.IPythonQtConsoleApp.ip = '127.0.0.1' <br>
<br>If I try to specify my network-facing interface IP with a flag, e.g.:<br>ipython qtconsole --ip=192.168.X.X<br><br>then it fails, printing a stack and the following:<br><br>RuntimeError: Can only launch a kernel on a local interface. Make sure that the '*_address' attributes are configured properly. Currently valid addresses are: ['127.0.0.1', '127.0.1.1', '0.0.0.0', '']<br>
</blockquote><div><br></div><div>This would suggest that our code that determines the available IPs on your system isn't working properly. We should probably relax this check, and trust the user to know their own IP.</div>
<div><br></div><div>What do you get with:</div><div><br></div><div>import socket</div><div>hostname = socket.gethostname()</div><div>socket.gethostbyname_ex(hostname)</div><div><br></div><div>?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>Following the documentation that 0.0.0.0 opens up the kernel to all interfaces, I try launching ipython with the ip tag set to 0.0.0.0, which does indeed launch a console. However, I can't then seem to connect to this instance anyway I try. The usual method (launching a new instance with the "--existing ..." flags) brings up a qtconsole, displaying the usual headers, but no prompt ever appears. The same is true if I append the extra flags to the second qtconsole of --ip=0.0.0.0 or --ip=192.168.1.2 and so on -- just a promptless console.<br>
</blockquote><div><br></div><div>That should definitely work, so it's presumably some kind of bug, but I can't think of what it would be.</div><div><br></div><div>ipython qtconsole --ip=0.0.0.0</div><div># copy '--existing...'</div>
<div><br></div><div>then connect with:</div>
<div><br></div><div>ipython qtconsole --ip=192.168.X.Y <paste></div><div># or if you are on the same machine:</div><div>ipython qtconsole --ip=127.0.0.1 <paste></div><div><br></div><div>You can't connect to 0.0.0.0, because it's a bind alias for listening on all interfaces, not a real address. Since you are on localhost, you might also try loopback interfaces when connecting, to see if maybe the issue confusing IPython's guess about local IPs is affecting how zeromq interprets 0.0.0.0.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>Is there a simple syntactical trick I'm missing, or is my use case is not what this system is designed for?<br></blockquote><div><br></div><div>Shouldn't be, there just appears to be something different about your system that we don't handle properly.</div>
<div><br></div><div>As for SSH, you need to set up tunnels. The parallel code will try to set up these tunnels for you, but the KernelManager used in the qt code doesn't use this yet, and you have to set them up yourself.</div>
<div><br></div><div>Let's say I start a qtconsole on machine `server`:</div><div><br></div><div>server > ipython qtconsole</div><div><div>[IPKernelApp] To connect another client to this kernel, use:</div><div>[IPKernelApp] --existing --shell=55460 --iopub=55461 --stdin=55462 --hb=55463</div>
</div><div><br></div><div>Which is now listening on localhost by default.</div><div><br></div><div>Now on machine `client`, I will need to set up tunnels to loopback on server:</div><div><br></div><div>client > ssh server -f -N -L 55460:<a href="http://127.0.0.1:55460">127.0.0.1:55460</a></div>
<div><div>client > ssh server -f -N -L 55461:<a href="http://127.0.0.1:55461">127.0.0.1:55461</a></div></div><div><div>client > ssh server -f -N -L 55462:<a href="http://127.0.0.1:55462">127.0.0.1:55462</a></div></div>
<div><div>client > ssh server -f -N -L 55463:<a href="http://127.0.0.1:55463">127.0.0.1:55463</a></div></div><div><br></div><div>(the `-f -N` just mean "run in the background, and don't to anything but tunnel")</div>
<div><br></div><div>That is to say, if *on client* I now try to connect to localhost:55460, the connection will be forwarded to localhost:55460 *on server*, etc.</div><div>So now I can just copy-paste the connection line to the client:</div>
<div><br></div><div>client > ipython qtconsole --existing --shell=55460 --iopub=55461 --stdin=55462 --hb=55463</div><div><br></div><div>and I will have a qtconsole that is using the same kernel as the one on the server.</div>
<div><br></div><div>The one extra step is that you might want to connect to a machine that is not visible from client. Let's say there is now a machine `login` that has direct access to server, and login is visible on the internet, but server is not.</div>
<div><br></div><div>The change on server is to listen on an external IP, either 0.0.0.0 or a specific interface:</div><div><br></div><div>server > ipython qtconsole --ip=0.0.0.0</div><div><div><div>[IPKernelApp] To connect another client to this kernel, use:</div>
<div>[IPKernelApp] --existing --shell=55460 --iopub=55461 --stdin=55462 --hb=55463</div></div></div><div><br></div><div>Now you need to tunnel slightly differently, because you want local ports on client to point to `server` via `login`, rather than `127.0.0.1` via `server`:</div>
<div><div><br></div><div>client > ssh login -f -N -L 55460:server:55460</div><div><div>client > ssh login -f -N -L 55461:server:55461</div></div><div><div>client > ssh login -f -N -L 55462:server:55462</div></div>
<div><div>client > ssh login -f -N -L 55463:server:55463</div></div></div><div><br></div><div>That is, when client asks for these ports on localhost, they will actually get the ports on server, using login as an intermediary.</div>
<div><br></div><div>Now, once again, you can connect the client to what it thinks is a local Kernel:</div><div><br></div><div><div>client > ipython qtconsole --existing --shell=55460 --iopub=55461 --stdin=55462 --hb=55463</div>
</div><div><br></div><div>I hope that clears things up a little bit. I know setting up multiple ssh tunnels is not the most obvious process.</div><div><br></div><div>-MinRK</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>Thanks<br><font color="#888888">Neil</font><div><div></div><div><br><br><br><div class="gmail_quote">
On Thu, Aug 4, 2011 at 9:48 PM, neil rabinowitz <span dir="ltr"><<a href="mailto:neil.rabinowitz@merton.ox.ac.uk" target="_blank">neil.rabinowitz@merton.ox.ac.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">hello<br><br>firstly, much credit is due to all who have contributed to the 0.11 release. i've been migrating the last couple of days, and i'm impressed with all you've done.<br>
<br>i'm trying to have a play around with the client/kernel architecture. in particular, i usually run instances of python on my lab server, which i access remotely via ssh (e.g. from elsewhere in the lab or at home). i'm wondering what is the standard protocol for securely connecting a qt console client to a remote kernel -- i can't seem to find appropriate documentation. could someone please point me in the appropriate direction?<br>
<br>best<br><font color="#888888">neil<br>
</font></blockquote></div><br>
</div></div><br>_______________________________________________<br>
IPython-User mailing list<br>
<a href="mailto:IPython-User@scipy.org" target="_blank">IPython-User@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
<br></blockquote></div><br>