树莓派ubuntuMATE 安装xrdp来进行显示图形的远程调试
在树莓派上调试显示图形界面的项目,纠结配显示器的问题。
pi本身有hdmi的接口,如果有多余的显示器直接连接的那最好,倘若接口不合适也可以配个转换器。
如果你不在乎那三头二百,花点钱为pi配个专用小屏显也是相当ok的。
但如果你买了个pi当玩具,没有多余的显示器,又纠结花钱买了小屏显之后会让它一直去吃灰;或者做项目时设备空间不足,不允许接显示器调试时,
就可以考虑局域网内远程控制的方案。
临时接个显示器配置,配置好之后,再脱离显示器,使用pc端或者手机端的远程连接进行控制和调试。
系统是ubuntuMATE 16.04
官方
http://xrdp.org/
xrdp - an open source RDP server
https://github.com/neutrinolabs/xrdp
安装
sudo apt-get install xrdp
robot@robot:~/Desktop$ sudo apt-get install xrdp
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
robot@robot:~/Desktop$ ps -A |grep apt
630 ? 00:00:00 apt.systemd.dai
robot@robot:~/Desktop$ sudo kill -SIGKILL 630
robot@robot:~/Desktop$ ps -A |grep apt
2100 ? 00:00:00 apt.systemd.dai
robot@robot:~/Desktop$ sudo kill -SIGKILL 2100
robot@robot:~/Desktop$ ps -A |grep apt
robot@robot:~/Desktop$ sudo apt-get install xrdp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
vnc4server xbase-clients
Suggested packages:
vnc-java x11-xfs-utils
The following NEW packages will be installed:
vnc4server xbase-clients xrdp
0 upgraded, 3 newly installed, 0 to remove and 914 not upgraded.
1 not fully installed or removed.
Need to get 1,741 kB/3,678 kB of archives.
After this operation, 5,496 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ports.ubuntu.com xenial-updates/universe armhf xbase-clients all 1:7.7+13ubuntu3.1 [4,696 B]
Get:2 http://ports.ubuntu.com xenial/universe armhf vnc4server armhf 4.1.1+xorg4.3.0-37.3ubuntu2 [1,539 kB]
Get:3 http://ports.ubuntu.com xenial-updates/universe armhf xrdp armhf 0.6.1-2ubuntu0.3 [197 kB]
Fetched 1,741 kB in 11s (146 kB/s)
Selecting previously unselected package xbase-clients.
(Reading database ... 247869 files and directories currently installed.)
Preparing to unpack .../xbase-clients_1%3a7.7+13ubuntu3.1_all.deb ...
Unpacking xbase-clients (1:7.7+13ubuntu3.1) ...
Selecting previously unselected package vnc4server.
Preparing to unpack .../vnc4server_4.1.1+xorg4.3.0-37.3ubuntu2_armhf.deb ...
Unpacking vnc4server (4.1.1+xorg4.3.0-37.3ubuntu2) ...
Selecting previously unselected package xrdp.
Preparing to unpack .../xrdp_0.6.1-2ubuntu0.3_armhf.deb ...
Unpacking xrdp (0.6.1-2ubuntu0.3) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu21.10) ...
Processing triggers for ureadahead (0.100.0-19) ...
dpkg: error processing package python-twisted-core (--configure):
package python-twisted-core is not ready for configuration
cannot configure (current status 'half-installed')
Setting up xbase-clients (1:7.7+13ubuntu3.1) ...
Setting up vnc4server (4.1.1+xorg4.3.0-37.3ubuntu2) ...
update-alternatives: using /usr/bin/vnc4server to provide /usr/bin/vncserver (vncserver) in auto mode
update-alternatives: using /usr/bin/Xvnc4 to provide /usr/bin/Xvnc (Xvnc) in auto mode
update-alternatives: using /usr/bin/x0vnc4server to provide /usr/bin/x0vncserver (x0vncserver) in auto mode
update-alternatives: using /usr/bin/vnc4passwd to provide /usr/bin/vncpasswd (vncpasswd) in auto mode
update-alternatives: using /usr/bin/vnc4config to provide /usr/bin/vncconfig (vncconfig) in auto mode
Setting up xrdp (0.6.1-2ubuntu0.3) ...
Processing triggers for systemd (229-4ubuntu21.10) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
python-twisted-core
E: Sub-process /usr/bin/dpkg returned an error code (1)
安装时python有个错误??先不管。。。。
robot@robot:~/Desktop$ echo $DESKTOP_SESSION
mate
robot@robot:~/Desktop$ echo "mate-session" > ~/.xsession
robot@robot:~/Desktop$ sudo service xrdp restart
robot@robot:~/Desktop$
"mate-session &" 后台运行连接不上,不知何解。。。。
win10打开远程桌面连接,登录。
见图就可以操作了。
这样我们就可以拔掉pi的显示器,使用局域网的pc机远程了。
有时调试项目,远程桌面还有这样的问题:
远程登录的界面与pi本地界面不同,问题如下
http://www.linuxdiyf.com/view_234750.html
求助:怎样实现远程桌面与本地桌面一致?
文中提到使用vnc服务
vnc:在本地桌面上运行 x0vncserver -PasswordFile=/root/.vnc/passwd
X0VNCSERVER文档
https://tigervnc.org/doc/x0vncserver.html
用法https://blog.csdn.net/x2008l/article/details/99702020,引用
x0vncserver display=':0.0' -securitytypes none
-nevershared 单用户访问
-alwaysshared 多用户访问
-maxidletime 60 60秒无操作中断
-rfbport 5900 5900端口连接
-securitytypes none 免密码
-rfbauth /root/.vnc/passwd passwd秘密文件
-hostsfile /root/.vnc/hosts hosts限制访问hosts内容
+192.168.6.0/24允许访问
-192.168.8.0/24拒绝访问
vncpasswd文档
https://tigervnc.org/doc/vncpasswd.html
首先vnc设置密码
robot@robot:~$ vncpasswd
Password:
Verify:
Couldn't open /home/robot/.vnc/passwd for writing
robot@robot:~$ sudo vncpasswd
[sudo] password for robot:
Password:
Verify:
Passwords don't match - try again
Password:
Verify:
robot@robot:~$
启动服务
robot@robot:~/Desktop$ sudo x0vncserver -PasswordFile=/home/robot/.vnc/passwd
可以设置个命令开机自启动。如前文https://blog.csdn.net/qq_38288618/article/details/104096606
sudo输入密码问题,例如123456为密码
echo '123456' | sudo -S x0vncserver -PasswordFile=/home/robot/.vnc/passwd
不过据说这样有安全风险问题?先解决问题,有待深入。
vncserver win10的远程桌面是不能连接的。因为协议不同,远程桌面使用 RDP协议,VNC是RFB协议。
https://blog.csdn.net/weixin_33726318/article/details/93852711
RFB与RDP的区别
RFB是在服务器端将窗口在显存中画好之后将图像传给客户端,客户端只充当一个图像解码显示的角色; RDP则将画图的工作交给了客户端,服务器需要了解客户端显示能力的具体情况,以便作出相应调整。
所以我们需要在windows上装一个VNC Viewer
VNC Viewer客户端(Windows版) v6.18.907 32位/64位 官方安装免费版
https://www.jb51.net/softs/605232.html
如图
手机端可以安装相关VNC Viewer app
如bvnc free ,,可以搜索自己顺手的app。
如图
好吧,现在的手机就成了树莓派的一个可以揣兜里的显示器了。
https://blog.51cto.com/zener/328687
VNC 服务器配置和调试 含 VNC同步TTY7
https://www.cnblogs.com/lvdongjie/p/9798279.html
安装vncserver, vncviewer--远程桌面
https://www.maixj.net/ict/sudo-zidong-mima-21899
sudo时,自动输入密码
cron定时执行脚本遇到的问题https://www.maixj.net/ict/cron-sh-21597