ssh -X


ssh -R 6050:127.0.0.1:6000 -p 22 ubuntu

exprot DISPLAY=”127.0.0.1:50

ssh -X ubuntu

export DISPLAY=localhost:10.0

mac端:

1
vim ~/.ssh/config

添加:

1
ForwardX11Trusted

安装 XQuartz

1
brew install xquartz --cask

Linux端:

1
sudo vim /etc/ssh/sshd_config

添加:

1
2
3
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
1
vim ~/.zshrc

添加:

1
export DISPLAY=localhost:10.0

​ 书中带言:DISPLAY=:0 表示 Linux 端本地使用GUI

登陆

1
ssh -X ubuntu

如果此登陆方式使用 pyqt 有问题

1
2
3
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

可以在 .zshrc 中添加:

1
export QT_DEBUG_PLUGINS=1

再运行,查看具体原因

1
2
3
4
5
qt.core.library: "/home/zhangzhiyu/miniconda3/lib/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so" cannot load: Cannot load library /home/zhangzhiyu/miniconda3/lib/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so: (libxcb-cursor.so.0: cannot open shared object file: No such file or directory)
qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/home/zhangzhiyu/miniconda3/lib/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so" : "Cannot load library /home/zhangzhiyu/miniconda3/lib/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/libqxcb.so: (libxcb-cursor.so.0: cannot open shared object file: No such file or directory)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

1
sudo apt install libxcb-cursor-dev

ssh user

1
ssh user@222.27.79.35

PassWord: lj523245

新建文件夹

1
2
3
cd CSIM
mkdir -p zhangzhiyu
cd zhangzhiyu; ls -lh

Jupyter

参照:
https://dummerfu.top/p/64572.html

$ colab 实现本地连接

$ 安装 jupyter

1
conda install notebook

$ 启用jupyter_http_over_ws jupyter 扩展程序(连接到本地需要

1
pip install jupyter_http_over_ws jupyter serverextension enable --py jupyter_http_over_ws

$ 启动jupyter 最后一行参数是为了挂载到本地后能打开自己的文件

虽然缺乏安全性,但是是最快解决403的方法,有时间再找找其他替代方案

1
jupyter notebook --NotebookApp.allow_origin='<https://colab.research.google.com>' --port=8899 --NotebookApp.port_retries=0 --NotebookApp.disable_check_xsrf=True

$ 优化

生成配置文件

1
2
3
jupyter notebook --generate-config
cd .jupyter
vim jupyter_config.py

更改参数

1
2
3
4
5
6
c.NotebookApp.allow_origin='<https://colab.research.google.com>'
c.port=8888
c.NotebookApp.port_retries=0
c.NotebookApp.disable_check_xsrf=True

c.Notebook_dir='/Users/erbiaoger/DAS' # 更改自己的工作路径

更改token

因为每次连接到本地运行都要输入token,可以将token设置为固定值也相当于password了

不过这样运行的时候命令行里面不会显示token具体值

1
c.NotebookApp.token='http://localhost:8888/?token=erbiaoger'

取消自动重定向

每次打开一个new tab很烦人我又不用jupyter写代码

1
c.NotebookApp.open_browser = False

后台运行

1
2
3
4
5
6
# 在上述命令的最后加一个 & ,则该命令产生的进程在后台运行,不会影响当前终端的使用(我们在只有一个bash的环境下)。
# ctrl c之后还在运行,但是关掉窗口就会停止
jupyter notebook &

# 在命令的开头加一个nohup,忽略所有的挂断信号,如果当前bash关闭,则当前进程会挂载到init进程下,成为其子进程,这样即使退出当前bash,其8000端口也可以使用。
nohup jupyter notebook &

Jupyter notebook 插件

1. 安装并激活 jupyter_contrib_nbextensions

1
2
3
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple flask
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user

2. 安装并启用 Jupyter Nbextensions Configurator

1
2
pip install jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
1
2
3
ssh -NL 8888:localhost:8891 zhangzhiyu


Matlab

\


文章作者: ZY
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 ZY !
评论
  目录