美文网首页
通过 SSH 端口转发搭建 Jupyter notebook 服

通过 SSH 端口转发搭建 Jupyter notebook 服

作者: 陈灿贻 | 来源:发表于2019-07-20 23:59 被阅读0次

    Host

    • python
    >> from notebook.auth import passwd
    >> passwd()
    Enter password:
    Verify password:
    'sha1:673a8456a8e8:4377bd9ee8dc33d4cb5a2011f7a89643de15c11c'
    
    • .jupyter-config.py
    # vi .jupyter-config.py
    c.NotebookApp.ip = 'localhost'
    c.NotebookApp.open_browser = False
    c.NotebookApp.port = 8081
    c.NotebookApp.password =u'sha1:c0792e86dce2:e6fe5ee529a238b0dc33f4f1960499d6fbd02927'     
    
    • start jupyter notebook
    nohup jupyter notebook --config=.jupyter-config.py >> nohup.out &!
    

    Client

    ssh -N -f -L 127.0.0.1:8888:127.0.0.1:8081 chencanyi2018@10.224.255.112 -p 5102 # Node A
    
    • -N:不执行任何命令
    • -f:后台运行
    • -L:转发端口
    • -vvv:调试

    跳板机

    sudo apt-get install autossh
    autossh -N -f -L 127.0.0.1:8888:127.0.0.1:8081 chencanyi2018@10.0.0.2 -p 22 # Node B
    ssh -N -f -L 127.0.0.1:8887:127.0.0.1:8888 chencanyi2018@116.196.81.58 -p 22 # Node C
    cat .zshrc
    # alias jupyter_gpu="ssh -N -f -L 127.0.0.1:8887:127.0.0.1:8888 chencanyi2018@116.196.81.58 -p 22"
    

    kill nohup

    ps -eaf | grep "jupyter" | grep -v grep | awk '{ print $2 }' | xargs kill -9
    

    References

    相关文章

      网友评论

          本文标题:通过 SSH 端口转发搭建 Jupyter notebook 服

          本文链接:https://www.haomeiwen.com/subject/iovplctx.html