一分钟搞定树莓派远程桌面

安装xrdp

打开树莓派终端,输入 sudoapt-get install xrdp ,等待xrdp安装完成

执行vncserver指令,(下面是执行结果)我们可以看到监听端口为 172.20.11.37:1 。

root@raspberrypi:~# vncserver
VNC(R) Server 6.4.0 (r39899) ARMv6 (Dec 7 2018 12:34:40)
Copyright (C) 2002-2018 RealVNC Ltd.
RealVNC and VNC are trademarks of RealVNC Ltd and are protected by trademark
registrations and/or pending trademark applications in the European Union,
United States of America and other jurisdictions.
Protected by UK patent 2481870; US patent 8760366; EU patent 2652951.
See https://www.realvnc.com for information on VNC.
For third party acknowledgements see:
https://www.realvnc.com/docs/6/foss.html
OS: Raspbian GNU/Linux 9, Linux 4.14.98, armv7l

Generating private key... done
xauth:  file /root/.Xauthority does not exist
On some distributions (in particular Red Hat), you may get a better experience
by running vncserver-virtual in conjunction with the system Xorg server, rather
than the old version built-in to Xvnc. More desktop environments and
applications will likely be compatible. For more information on this alternative
implementation, please see: https://www.realvnc.com/doclink/kb-546

Running applications in /etc/vnc/xstartup

VNC Server catchphrase: "Convert indigo Jessica. Salt pure postal."
             signature: 1a-03-2c-91-75-3e-30-5d

Log file is /root/.vnc/raspberrypi:1.log
New desktop is raspberrypi:1 (172.20.11.37:1)

安装使用VNC Viewer登录远程主机

在Windows系统上下载安装 VNC Viewer v6.19.715 ,在箭头位置输入上面的 ‘’IP+端口 ‘’按回车输入你的远程主机的账号密码登录即可,如下图
在这里插入图片描述
登录成功。
在这里插入图片描述

下面是配置VNC的开机自启

修改vnc密码:vncpasswd [登录用]

首先新建服务文件

sudo nano /etc/init.d/vncserver

然后 复制下面的内容 右键粘贴进去

#!/bin/sh
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop vncserver
### END INIT INFO
 
# More details see:
# http://www.penguintutor.com/linux/vnc
 
### Customize this entry
# Set the USER variable to the name of the user to start vncserver under
export USER='pi'       #登录用户名
### End customization required
 
eval cd ~$USER
 
case "$1" in
  start)
    # 启动命令行。此处自定义分辨率、控制台号码或其它参数。
    su $USER -c '/usr/bin/vncserver -depth 16 -geometry 1024x768 :1'
    echo "Starting VNC server for $USER "
    ;;
  stop)
    # 终止命令行。此处控制台号码与启动一致。
    su $USER -c '/usr/bin/vncserver -kill :1'
    echo "vncserver stopped"
    ;;
  *)
    echo "Usage: /etc/init.d/vncserver {start|stop}"
    exit 1
    ;;
esac
exit 0

然后 Ctrl+O 回车 保存

然后 Ctrl+X退出文本编辑器

然后 修改权限

sudo chmod 777 /etc/init.d/vncserver

然后 添加开机启动项

sudo update-rc.d vncserver defaults

最后 重启树莓派

sudo reboot

如果不出意外 树莓派开机后 就可以连接VNC了

转自树莓派3B远程VNC的设置(包括开机启动)

这样启动改脚本用service 命令就可以

sudo service vncserver start   #启动

sudo service vncserver stop    #停止
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yfw&武

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值