How to accept connections for ipython from other computers?

前端 未结 2 970
情话喂你
情话喂你 2021-01-31 01:38

I run ipython 0.12.1 on Ubuntu 12.04. You can run it in browser using notebook interface by running:

ipython notebook --pylab

Configuration fil

2条回答
  •  忘掉有多难
    2021-01-31 02:30

    The accepted answer/information is for an old version. How to enable remote access to your new jupyter notebook? I got you covered

    First, generate a config file if you don't have it already:

    jupyter notebook --generate-config
    

    Notice the output of this command as it would tell you where the jupyter_notebook_config.py file was generated. Or if you already have it, it will ask you if you would like to overwrite it with the default config. Edit the following line:

    ## The IP address the notebook server will listen on.
    c.NotebookApp.ip = '0.0.0.0' # Any ip
    

    For added security, type in a python/IPython shell:

    from notebook.auth import passwd; passwd()
    

    You will be asked to input and confirm a password string. Copy the contents of the string, which should be of the form type:salt:hashed-password. Find and edit the lines as follows:

    ## Hashed password to use for web authentication.
    #  
    #  To generate, type in a python/IPython shell:
    #  
    #    from notebook.auth import passwd; passwd()
    #  
    #  The string should be of the form type:salt:hashed-password.
    c.NotebookApp.password = 'type:salt:the-hashed-password-you-have-generated'
    
    ## Forces users to use a password for the Notebook server. This is useful in a
    #  multi user environment, for instance when everybody in the LAN can access each
    #  other's machine through ssh.
    #  
    #  In such a case, server the notebook server on localhost is not secure since
    #  any user can connect to the notebook server via ssh.
    c.NotebookApp.password_required = True
    
    ## Set the Access-Control-Allow-Origin header
    #  
    #  Use '*' to allow any origin to access your server.
    #  
    #  Takes precedence over allow_origin_pat.
    c.NotebookApp.allow_origin = '*'
    

    (Re)start your jupyter notebook, voila!

提交回复
热议问题