Wednesday, 22 February 2017

close the SSH tunnel on the local machine


Look for the process and kill it manually:
local_user@local_host$ ps aux | grep localhost:8889
local_user 18418 0.0 0.0 41488 684 ? Ss 17:27 0:00 ssh ---L localhost:8888:localhost:8889 remote_user@remote_host
local_user 18424 0.0 0.0 11572 932 pts/6 S+ 17:27 0:00 grep localhost:8889
local_user@local_host$ kill -15 18418
Alternatively, you can start the tunnel without the -f option. The process will then remain in the foreground and can be killed with ctrl-c.

Configure Jupyter Notebook via ssh remotely


On your remote computer, if there is no display or monitor still you can configure your local computer display and utilize remotely GPU. Here, we are talking about Jupyter Notebook or any IPYTHON Notebook which can open through local computer and via ssh remotely access to GPU can be possible.

On your local computer, you want to open and manipulate a jupyter notebook running on a remote computer. We will do this by opening an SSH tunnel.


1. On the remote machine, start the JUPYTER notebooks server:

remote_user@remote_host$ jupyter notebook --no-browser --port=8889

Usually IPython opens a browser to display the available notebooks, but we do not need that so we use the option --no-browser. We also change the port to 8889, for no other reason than to show how this is done.

2. On the local machine, start an SSH tunnel, which will forward the port used by the remotely running IPython instance to a port on the local machine, where it can be accessed in a browser just like a locally running IPython instance.
local_user@local_host$ ssh -N -f -L localhost:8888:localhost:8889 remote_user@remote_host
The first option -N tells SSH that no remote commands will be executed, and is useful for port forwarding. The second option -f tells that SSH will got to background, so the local tunnel-enabling terminal remains usable. And -L lists the port forwarding configuration(8889 to 8888).


3. Now open your browser on the local machine and type in the address bar
localhost:8888 
which will redirect you to the page where it asks for token or password. 

4. For token, you can check the following command on remote server
remote_user@remote_host$ jupyter notebook list

that will give you the url where token= X, take this X and put in the textbox .