Setup headless Raspberry Pi 3 model B+
Here I will set up Raspberry Pi in headless mode so that I can control it through ssh without monitor, keyboard and mouse attached on it.
The first thing to do is to write Raspberry Pi operating system to a SD card. While it is recommended to use NOOBS for beginners, NOOBS use graphic interface which cannot be displayed in headless mode. Thus, I will go for Raspbian, which is a version of debian running on Raspberry Pi.
Insert SD card into computer and use Etcher to burn Raspbian on it. Raspbian comes with a desktop version and a lite version. Desktop version contains a graphic user interface which might be handy in the future. If you are absolutely sure you will not use graphic user interface, namely X Window System, you can use lite version.
Once the image is burned, go to root directory in the SD card.
To enable ssh, do
It will create a file named ssh under root directory.
Then add another file called wpa_supplicant.conf under root directory as
Reject SD card from computer and insert it into Raspberry Pi board. Connect power onto mini USB port of Raspberry Pi board.
Once it is powered, a red light will show up on side of Raspberry Pi board. Green light indicates reading of SD card.
You can ssh onto it by
And the default password is raspberry. The domain name raspberrypi.local is mDNS name, which is supported by most modern OS.
Once you are in, use raspi-config to permanently enable ssh by
Choose Interfacing Options, then enable ssh.
You should also change your password by
You can also protect your password by using wpa_passpharase to replace clear text password in /etc/wpa_supplicant/wpa_supplicant.conf
It will ask password. Then copy and paste the calculated psk onto network section without the quotation.
You can also enable VNC server on Raspberry Pi by
Choose Interfacing Options, then enable vnc. Then find a VNC viewer to connect to it.
Finally, update softwares by
sudo apt-get update
sudo apt-get dist-upgrade
You should also learn how to secure Raspberry Pi if you plan to use it as a server.
It is also common to generate new ssh key like this:
ssh-keygen -t rsa -b 4096 -C "email@example.com"