0%

ssh x11 forward太慢了,真的。

Xpra除了很快,还可以后台运行gui应用,被称为screen for X11。还可以远程运行整个桌面。

下面使用macos远程使用debian buster系统上的gui application

安装

debian端:

1
2
3
$ wget -q https://xpra.org/gpg.asc -O- sudo apt-key add -
$ sudo add-apt-repository "deb https://xpra.org/ buster main"
$ sudo apt update && sudo apt install xpra -y

mac端:
下载Xpra.pkg安装即可。
或者

1
$ brew cask install xpra

运行

通过ssh隧道运行

linux/macos平台:

一次性运行gui应用,结束时自动关闭xpra服务

1
$ xpra start ssh://user@host --start-child=xlogo --exit-with-children=yes --speaker=off --webcam=no

启动gui应用,结束时不关闭xpra服务,可以再次附加到gui应用程序

1
$ xpra start ssh://user@host --start-child=xlogo

断开后可以重新附加到已经运行的gui应用

1
$ xpra attach ssh://user@host

windows平台:

1
cmd> xpra_cmd start ssh://user@host --ssh="C:\\\\Program Files\\\\putty\\\\Plink.exe -ssh -noagent -i c:\\\\***.ppk -P 22" --start-child=xlogo --exit-with-children=yes --speaker=off --webcam=no

其他命令

列出所有会话

1
$ xpra list

终止所有会话

1
$ xpra stop

输入法
服务器上安装ibus

1
$ sudo apt install ibus-pinyin

配置ibus

1
$ xpra start ssh://user@host --exit-with-children=yes --speaker=off --webcam=no --input-method=IBus --start-child="ibus-setup"

运行firefox,同时启动ibus输入法

1
$ xpra start ssh://user@host --start-child=firefox --exit-with-children=yes --speaker=off --webcam=no --input-method=IBus --start-child="ibus-daemon -x -d -r"

其他请参考xpra --help

References:
[1]manual
[2]FAQ
[3]GUIDE: Work remotely on a Linux server from local Mac

pgadmin4无法启动,有类似错误

1
AttributeError: 'module' object has no attribute 'GSSException'

是因为python3-paramiko与python3-gssapi冲突,启动python3,import paramiko会报错:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Python 3.7.3 (default, Apr 3 2019, 05:39:12) 
\[GCC 8.3.0\] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/paramiko/__init__.py", line 22, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/usr/lib/python3/dist-packages/paramiko/transport.py", line 38, in <module>
from paramiko.auth_handler import AuthHandler
File "/usr/lib/python3/dist-packages/paramiko/auth_handler.py", line 72, in <module>
from paramiko.ssh_gss import GSSAuth, GSS_EXCEPTIONS
File "/usr/lib/python3/dist-packages/paramiko/ssh_gss.py", line 55, in <module>
GSS_EXCEPTIONS = (gssapi.GSSException,)
AttributeError: module 'gssapi' has no attribute 'GSSException'

临时的解决办法就是卸载掉python3-gssapi

1
$ sudo apt remove python3-gssapi

在debian buster系统上以服务方式部署pgadmin4

配置

/usr/share/pgadmin4/web目录下添加config_local.py文件,内容如下:

1
2
3
4
LOG_FILE = '/var/log/pgadmin/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin/sessions'
STORAGE_DIR = '/var/lib/pgadmin/storage'

然后执行:

1
# python3 setup.py

配置过程中输入用户登录认证信息,email和password,访问服务时需要提供

运行

使用gunicorn来运行python服务,先安装gunicorn

1
# apt install gunicorn3

启动服务

1
2
3
4
5
$ sudo gunicorn3 --bind 0.0.0.0:80 \\
--workers=1 \\
--threads=25 \\
--chdir /usr/share/pgadmin4/web \\
pgAdmin4:app

然后打开浏览器,输入服务所在的ip地址即可。

References:
[1]Server Deployment

firefox

加速X11 forward速度

1
$ ssh -XC4 user@host firefox --no-remote

chrome

直接下载chrome for linux amd64 latest

1
$ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

安装

1
2
3
$ sudo dpkg -i google-chrome-stable_current_amd64.deb
$ sudo apt install -f
$ sudo apt install upower

chrome会将自己设置为x和gnome默认的浏览器

1
2
3
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/x-www-browser (x-www-browser) in auto mode
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/gnome-www-browser (gnome-www-browser) in auto mode
update-alternatives: using /usr/bin/google-chrome-stable to provide /usr/bin/google-chrome (google-chrome) in auto mode

运行

1
$ ssh -YC4 user@host google-chrome --disable-gpu --temp-profile

但仍然无法运行成功,会不停的出现GCM通道请求失败错误

1
\[17069:17069:0202/170630.407817:ERROR:gcm_channel_status_request.cc(145)\] GCM channel request failed.

GCM是Google Cloud Messaging,google推出firebase云后,更名为FCM(Firebase Cloud Messaging),看样子是Great Fucking Wall的锅

确保安装xcode和brew

安装编译工具和部分依赖

1
$ brew install automake libtool boost curl lzlib libsigc++ openssl xmlrpc-c

编译安装libtorrent

1
2
3
4
5
6
$ git clone https://github.com/rakshasa/libtorrent.git
$ cd libtorrent
$ ./autogen.sh
$ CC=clang CXX=clang++ CXXFLAGS="-Wno-deprecated-declarations -O3 -std=c++11 -stdlib=libc++ -I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib" ./configure
$ make
$ make install

libtorrent安装到/usr/local/lib

编译安装rtorrent

1
2
3
4
5
6
7
$ git clone https://github.com/rakshasa/rtorrent.git
$ cd rtorrent
$ ./autogen.sh
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
$ CC=clang CXX=clang++ CXXFLAGS="-Wno-deprecated-declarations -O3 -std=c++11 -stdlib=libc++ -I/usr/local/opt/openssl/include" LDFLAGS="-L/usr/local/opt/openssl/lib" ./configure --with-xmlrpc-c
$ make
$ make install

rtorrent安装到/usr/local/bin

运行

1
$ rtorrent

默认配置文件为~/.rtorrent.rc

References:
[1]libtorrent and rtorrent on mac.sh
[2]rTorrent cheatsheet
[3]Navigating

alacritty在使用wayland的系统上无法切换出中文输入法,将alacritty菜单项执行的命令更改为:

1
env WINIT_UNIX_BACKEND=x11 alacritty

这样将渲染后端更改为x11

比如~/.local/share/applications/alacritty.desktop

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
\[Desktop Entry\]
Type=Application
TryExec=alacritty
Exec=env WINIT_UNIX_BACKEND=x11 alacritty
Icon=Alacritty
Terminal=false
Categories=System;TerminalEmulator;

Name=Alacritty
GenericName=Terminal
Comment=A cross-platform, GPU enhanced terminal emulator
StartupWMClass=Alacritty
Actions=New;

\[Desktop Action New\]
Name=New Terminal
Exec=alacritty

下载

下载64位安装包

安装

1
2
3
$ sudo apt install libqt4-declarative
$ sudo dpkg -i sogoupinyin_2.3.1.0112_amd64.deb
$ sudo apt install -f

如果不安装libqt4-declarative,搜狗输入法无法正常使用,并且会报
“搜狗输入法异常:删除~/.config/SogouPY并重新启动”,
如果终端内输入命令sogou-qimpanel,会提示:

1
2
$ sogou-qimpanel
sogou-qimpanel: error while loading shared libraries: libQtDeclarative.so.4: cannot open shared object file: No such file or directory

配置
安装完毕后,运行fcitx-config-gtk3或者fcitx-configtool,然后在input method页签内点击+号添加sogou pinyin输入法,搜索输入法时去掉“only show current language”选项。

1
2
$ sudo mv /var/lib/dpkg/info/PACKAGE_NAME.* /tmp/
$ sudo dpkg --remove --force-remove-reinstreq PACKAGE_NAME