Howto: Installing Raspberry PI 4 Headless (VNC) With Rpi-imager and Pictures
by rothoma2 in Circuits > Raspberry Pi
3750 Views, 12 Favorites, 0 Comments
Howto: Installing Raspberry PI 4 Headless (VNC) With Rpi-imager and Pictures
I plan to use this Rapsberry PI in a bunch of fun projects back in my blog. Feel free to check it out.
I wanted to get back into using my Raspberry PI but I didn't had a Keyboard or Mouse at my new location. It was a while since I setup a Raspberry PI so I wanted to refresh the current simple way to do it and see what issues I could came across the way.
This you will need:
- Raspbery PI.
- MicroSD 32GB
- MicroSD adapter (maybe needed to read your SD into your laptop).
- Energy Plug for your Raspberry.
We setup this Raspberry PI with Raspberry PI OS, via Headless mode with SSH and VNC access. I plan to use this one for Software Define Radio projects like this one, so I needed a GUI which is how this Raspberry PI is setup.
Install RPI-Imager
In the past there were other ways to setup the image for a rapsberry pi, but most of them were not so easy to use. In 2020 the best way is to use the rpi-imager
If you are using linux, install it with the following command.
robert@robert-enreach:~$ sudo snap install rpi-imager rpi-imager v1.4 from Alan Pope (popey) installed
Install Image on the MicroSD With Rpi-imager
Run rpi-imager from the command line. You will get a graphical interface to select which version of OS you want to install in your raspberry pi, and select the microsd card you want to install to.
robert@robert-enreach:~$ rpi-imager
For a Headless Installation Add an Ssh File.
In my particular case I just had a Laptop at home and I didn't had any spare Mouse, Keyboard or Screen I could connect to the Raspberry. I could have maybe use my TV but that seems too complex. I rather went with a Headless Installation.
This means you will connect to the Raspberry Pi through the network, and use SSH to enable for VNC access to the Raspberry. On recent versions the SSH comes disabled so you need to add an SSH file on the boot partition, as shown in the picture. Keep in mind to add it on the boot partition as you might see several when the MicroSD is connected to your OS, I had an issue with this a few times.
Connect to the Network, Find the IP Address and Setup DHCP Binding.
This step will vary from the pictures because you will likely have a different Router than I have. In my case I have a Draytek Router, which has quite some features. Basically you will like to get familiar with your Home Router and find a few things. You will probably have some area for ARP or DHCP on your Router so you can see the Binding created by the Raspberry.
The Raspberry Pi uses a raspberry PI name by default so you can find it easily. In this case I setup an DHCP binding so the Raspberry Pi will always take the same IP Address 192.168.1.40
The you should be able to ping it from your Router, and later from your computer and should be reachable now.
Connect by SSH, Change Password and Set VNC Access.
By now you were able to ping your Raspberry PI on the network, and try to ssh into it. SSH should be enabled because you added an SSH file into the boot partition of the SD card for Rapsberry Pi.
Use the following default credentials for ssh: pi / raspberry.
robert@robert-enreach:~$ ssh pi@192.168.1.40 The authenticity of host '192.168.1.40 (192.168.1.40)' can't be established. ECDSA key fingerprint is SHA256:no3JtIRZRG2SqSbWHg1sVC35mBjHyeX9SgDr81uPeuU. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.1.40' (ECDSA) to the list of known hosts. pi@192.168.1.40's password: Linux raspberrypi 5.4.51-v7l+ #1333 SMP Mon Aug 10 16:51:40 BST 2020 armv7l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Sat Sep 26 13:41:55 2020 SSH is enabled and the default password for the 'pi' user has not been changed. This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password. Wi-Fi is currently blocked by rfkill. Use raspi-config to set the country before use.
pi@raspberrypi:~ $ passwd Changing password for pi. Current password: New password: Retype new password: passwd: password updated successfully
pi@raspberrypi:~ $ sudo raspi-config
You can check now that your Raspberry PI is listening on port SSH 22, and Port VNC 5900
pi@raspberrypi:~ $ netstat -tupln (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:5900 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp6 0 0 :::5900 :::* LISTEN - tcp6 0 0 :::22 :::* LISTEN - udp 0 0 0.0.0.0:68 0.0.0.0:* - udp 0 0 0.0.0.0:47273 0.0.0.0:* - udp 0 0 0.0.0.0:5353 0.0.0.0:* - udp6 0 0 :::42453 :::* - udp6 0 0 :::5353 :::* -
Connect Via RealVNC
I had some trouble connecting via VNC because I kept getting this error that is quite common. This is related to the type of encription used by the vnc server on the Rapsberry PI. Installing RealVNC vncviewer was the best alternative to this. You can download it from this link: RealVNC Viewer
Use the credentials you setup before pi / password.
Enjoy Your Rapsberry PI
You can enjoy now your Raspberry. This one fresh installed with a GUI consumes around 5% CPU and has around 1.5GB of free Memory. I will try to get my hands into the 4GB Memory Model in the future.