Raspberry Pi 4B raspiberry set vnc remote login

    Raspberry Pi enables remote login, which can be set through raspi-config, but the image installed here may not be the official image, resulting in raspi-config settings not taking effect. The earlier version may select Interfacing Options through raspi-config, select Enable VNC to install realvnc-vnc-server, but this package warehouse has not provided downloads recently, even through apt install, it cannot be installed, only deb files can be downloaded for installation .

    Today I will introduce the setting of another remote service installation method, vino-server.

    1 apt install vino

sudo apt install vino

    2 Modify configuration /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml

     Add the following to the configuration file:

<key name='enabled' type='b'>
   <summary>Enable remote access to the desktop</summary>
   <description>
        If true, allows remote access to the desktop via the RFB
        protocol. Users on remote machines may then connect to the
        desktop using a VNC viewer.
   </description>
   <default>false</default>
</key>

    3 Set the gnome compilation mode

sudo glib-compile-schemas /usr/share/glib-2.0/schemas

    4 Set the login without encryption and confirmation, and set the vnc password . (The following commands are executed on the command line)

gsettings set org.gnome.Vino require-encryption false
gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino authentication-methods "['vnc']"
gsettings set org.gnome.Vino vnc-password $(echo -n '123456'|base64)

   The vnc password here is 123456, which can be set according to your actual situation. 

   In fact, it is basically configured here. If you are connected to the monitor, you can run /usr/lib/vino/vino-server directly. After it starts, it will start the vino service and listen to port 5900, then you can run Logged in remotely.

/

    5 Set up autostart, add the vino-server.desktop file under the current user directory .config/autostart, the content is as follows:

[Desktop Entry]
Type=Application
Name=Vino VNC server
Exec=/usr/lib/vino/vino-server
NoDisplay=true

    If the autostart directory does not exist, it can be added manually.

    This vino-server.desktop will run directly after the user enters the desktop. In practice, our Raspberry Pi may not be connected to the display in many cases. At this time, because the desktop cannot be accessed, the service will not start, so the remote vnc cannot be connected.

    Then we will solve the following problems:

   ①, user automatic login

    ② After logging in, enter the desktop

    You may find it strange that after automatic login, isn’t it just entering the desktop? In fact, the Raspberry Pi has a mechanism, that is, after automatic login, it will also detect the high-definition multimedia interface, that is, the HDMI interface. It only senses that there is a device connected. It will go to the desktop.

    The first automatic login solution is to add lightdm configuration, we modify /etc/lightdm/lightdm.conf

[SeatDefaults]
autologin-user=ubuntu

    My username here is ubuntu. The actual configuration needs to be configured according to your own device. If lightdm.conf does not exist, create it.

    If you are connected to a monitor, usually when you have a password, when you enter the system, you will stay at the user input password, and you will enter the desktop after entering the correct password. This configuration solves the problem of entering the system without entering a password.

    After the second login, you need to modify /boot/config.txt or /boot/firmware/config.txt when you enter the desktop. For my Raspberry Pi 4B, I want to modify /boot/firmware/config.txt and add the following configuration:

hdmi_force_hotplug=1
hdmi_drive=2

 

   After that, you can automatically log in and enter the desktop after restarting. As shown below, it is a screenshot of using mobaxterm to remotely log in to the Raspberry Pi via vnc:

 

The session of mobarxterm has the option of vnc. When clicking, you need to enter the remote host ip. After clicking OK, you are required to enter the vnc password. This password is the vnc password we set in step 4 of      the vino installation configuration above. It is not a Raspberry Pi user . password. 

   Some say that automatic login can modify /etc/systemd/system/getty.targets.wants/[email protected]

    In the ExecStart command, remove the -o '-p -- \\u' option and add --autologin ubuntu. If you are a root user, set --autologin root. I modified it here, but it didn't take effect, so I finally used the method of modifying the lightdm configuration.

    In addition, if the raspi-config configuration is good, you can also log in automatically through raspi-config and set Boot Options, select B1 Desktop / CLI and select B4 Desktop Autologin:

    However, my configuration does not take effect, the version of the raspi-config tool may be wrong. 

Guess you like

Origin blog.csdn.net/feinifi/article/details/132428655