Connect ipython-notebook via SSH tunnel from a remote location - ssh

I'm trying to open an ipython-notebook (which is running on a server) on a macbook from a remote location through an ssh tunnel but no data received.
This is the command for the SSH tunnel
ssh -L 5558:localhost:5558 -N -t -x user#remote-host
and this is the command I used to lunch the notebook form the server
ipython notebook --pylab=inline --port=5558 --ip=* --no-browser --notebook-dir notebooks
Than I tried to open it on a new tab with this remote-host:5558 but no data received.
Thanks in advance!

The directive -L AAAA:somehost:BBBB will cause SSH to listen on port AAAA on localhost (the machine the ssh command is run on) and forward any connection to that port, over the SSH session, to the host somehost port BBBB. So, you need to open http://localhost:5558/ in the browser on the machine you run the ssh command on.

Read this: How do I add a kernel on a remote machine in IPython (Jupyter) Notebook?
Remote jupyter kernel/kernels administration utility (the rk) here: https://github.com/korniichuk/rk

Related

Multiple jumps ssh tunnel, one command line

I'm currently connecting my local machine with the target running commands in my local (mobaxterm), in pivotonone and pivottwo, this is the flow of data:
mobaxterm <--- pivotone <--- pivottwo <--- target
These are the commands that I run on each machine:
local(mobaxterm)
ssh -L 5601:127.0.0.1:5601 root#pivotone
pivotone
ssh -L 5601:127.0.0.1:5601 root#pivottwo
pivottwo
ssh -L 5601:127.0.0.1:5601 root#target
I was wandering if I could do the same but with just one command in my mobaxterm machine?
You don't need the -L option to manage jump hosts.
ssh -J root#pivotone,root#pivottwo root#target
You can automate this in your .ssh/config file
Host target
ProxyJump root#pivotone,root#pivottwo
Then you can simply run
ssh root#target

Putty multihop tunnel replicate in bash

Im experiencing a problem replicate my putty ssh tunneling with Cmder bash (on windows machine).
1. I want to access web interface on port 7183 on server_2. To get there I have to go through jump_server first and and tunnel twice, as from the jump_server, only visible port is 22.
Steps with putty:
1. connect to jump_server with tunnel (L22 server_2:22) using username_1
2. connect to localhost with tunnel (L7183 localhost:7183) using username_2
After that, Im able to access the web interface when I type localhost:7183 into browser on my local machine.
Now Im trying to reproduce this in Cmder, but I havent been able to do that with one big command, nor 2 separate commands:
ssh -L 7183:localhost:7183 username_1#jump_server ssh -L 22:localhost:22 -N username_2#server_2 -vvv
This is only the last command I used as I tried interchanging ports and hosts without success.
2. Is the syntax different when I want to open port 12345 on my local machine and have it forwarded to port 21050 on server_2 or that would be remote tunneling?
Finally managed to achieve the 1. question with:
ssh username_1#jump_server -L 22:server_2:22 -N -vvv
ssh -L 7183:localhost:7183 username_2#localhost
Now Im albe to access the web interface from server_2 on my localhost:7183

SSH connection to jupyter notebook opens but browser unable to connect

I have a bizarre problem with my SSH connection. I am trying to connect to Ubuntu server from Windows client (local network, Bitvise SSH client).
jupyter notebook --no-browser --port=8885
Everything launches as normal. I then go to my client
ssh -p 2222 -N -f -L 8800:localhost:8885 user#server
Everything seems normal and I get in. I then go my browser and try localhost:8800 and localhost:8885. Neither responds. Any tips would be appreciated. Many thanks.

Debug port forwarding for using Jupyter notebook remotely

I am trying to use Jupyter notebook on a remote computer. The setup is as follows: I have my home laptop, which can ssh to a specific computer on my university's network (e.g., gateway.myuniv.edu). Once I am logged to gateway.myuniv.edu, I can ssh to the computer on which I would like to run the Jupyter notebook server (e.g. cluster.myuniv.edu).
What works: I can run the server on the gateway and connect to it from my laptop using local port forwarding, as follows:
On gateway.myuniv.edu: $ jupyter notebook --no-browser --port 8888
On my laptop: $ ssh -v -N -L 9000:localhost:8888 myusername#gateway.myuniv.edu
Then on my laptop's browser, I open the url: http://localhost:9000
What doesn't work: I don't want to run the server on the gateway, since I can't do heavy computations there. I tried to do the following:
On cluster.myuniv.edu: $ jupyter notebook --no-browser --port 8888
On my laptop: $ ssh -v -N -L 9000:cluster.myuniv.edu:8888 myusername#gateway.myuniv.edu
Then on my laptop's browser, I open the url: http://localhost:9000. This doesn't work: SSH says that the connection is refused.
I don't understand why this would happen and how to debug this, would be happy for any help. Thanks!
The issue is that you are forwarding port :8888 on cluster.myuniv.edu to port :9000 on gateway.myuniv.edu and then forwarding port :8888 on gateway.myuniv.edu to port 9000 on your laptop.
The solution would the following:
On cluster.myuniv.edu: $ jupyter notebook --no-browser --port 8888
On gateway.myuniv.edu: $ ssh -v -N -L 8888:localhost:8888 myusername#cluster.myuniv.edu
On laptop: $ ssh -v -N -L 9000:localhost:8888 myusername#gateway.myuniv.edu
I would also recommend that you run Jupyter notebook (on the cluster) and the ssh tunneling (on the gateway) using Tmux or Screen so it remains active even if you close terminal
You can use gateway.myuniv.edu as a Jump (ssh -J) host.
So start jupyter notebook on your cluster as you normally do:
jupyter notebook --no-browser --port 8888
On your local laptop: ssh username#cluster.myuniv.edu -J username#gateway.myuniv.edu -L 8888:localhost:8888 -N

Tunelling VNC through two ssh hops

I've long seeked a solution to tunnel to a machine behind a firewall, passing VNC (or other ports) through. Like explained in this old usenet post, which I'll recap here:
I have to log through an intermediate machine, something like:
local $ ssh interim
interim $ ssh remote
remote $ ...any commands...
This works fine. But now I am trying to tunnel a vnc session from remote to local and I can't find the magic incantation, using either one or two steps.
I recently found a wonderfully simple and adaptable solution: simply tunnel the ssh to the target system through the connection to the firewall. Like such:
local $ ssh -L 2222:remote:22 interim
interim $ ...no need to do anything here...
In another local console you connect to localhost on port 2222, which is actually your remote destination:
local $ ssh -C -p 2222 -L 5900:localhost:5900 localhost
remote $ ...possibly start you VNC server here...
In yet another local console:
local $ xtightvncviewer :0
It's that simple. You can add any port forwarding you want to the 2nd command (-L localport:localhost:remoteport) just like if there wasn't any intermediate firewall. For instance for RDP: -L 3389:localhost:3389