Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
8
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

posted at

updated at

Jupyter Labをリモートからアクセスできるようにする

はじめに

研究室のiMacやLinuxサーバーの方がそりゃあスペックが良いので,普段使用しているJupyterLabをリモートからでも使用できるようにするときの設定メモです.

こちらのjupyter labをリモートから使うを参考にさせていただきました.というかほとんどこのままです.

環境

  • python3.6
  • Ubuntu18.04 (macOS 10.14.6でも試しました)
  • jupyter-notebook 6.0.2
  • jupyter lab 1.1.4
  • ipython 7.9.0

手順

1.jupyterconfig.pyの作成

$ jupyter lab --generate-config
Writing default config to: /home/okuda/.jupyter/jupyter_notebook_config.py

2. ipythonでパスワードのハッシュ値を作成

$ ipython
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.9.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from IPython.lib import passwd                                                                                                                      

In [2]: passwd()                                                                                                                                            
Enter password: 
Verify password: 
Out[2]: 'sha1:xxxxxxxxx'

3. config.pyを設定

$ nano ~/.jupyter/jupyter_notebook_config.py

で,必要なところを編集.

~/.jupyter/jupyter_notebook_config.py
c = get_config()
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.open_browser = False
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 9999
c.NotebookApp.allow_remote_access = True
c.NotebookApp.password = 'sha1:xxxx' 

4. sshでポートフォワーディングで接続

$ ssh -p ポート番号 [user]@[ip] -NL 9999:localhost:9999

Jupyter Labを起動して,

http://localhost:9999/
にアクセスすればOKです.

~/.ssh/config
Host xxx
    HostName xxx
    User xxx
    Port xxx
        IdentityFile ~/.ssh/id_rsa_xxx
    LocalForward 9999 localhost:9999

みたいなのかくと,便利!

お疲れ様です.

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
8
Help us understand the problem. What are the problem?