Raspberry Pi comes with HDMI mini socket, and the Adapter HDMI mini to HDMI costs 4-5 €. However, I did not have one laying around so I flashed the Micro SD card I had and added the wifi configuration to it.
Then I can SSH directly to the box using the dynamic IP address my router provides.
-
Stick the Micro SD to laptop with an adapter
-
Download Raspberry Pi OS Lite from https://www.raspberrypi.org/software/operating-systems/
-
Use a flasher tool, for example Etcher. Flashing wipes all data from the card!
-
Create file
wpa_supplicant.conf
with this content:ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="REPLACE_THIS_WITH_WIFI_NAME" psk="REPLACE_THIS_WITH_WIFI_PASSWORD" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP auth_alg=OPEN }
The file will be editable later on in location
/etc/wpa_supplicant/wpa_supplicant.conf
inside the Raspberry Pi. -
Create an empty file
ssh
. -
Copy both files onto the root of the flashed Micro SD.
-
Find out the current Pi's IP address, for example with Terminal command
-
(which lists all devices on your local network)
arp -a
-
Boot the Raspberry Pi and SSH to it:
ssh [email protected] #
-
Disable IPv6
Edit system configuration file.
$ sudo nano /etc/sysctl.conf # Add this to the end of the file net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 net.ipv6.conf.lo.disable_ipv6=1 net.ipv6.conf.eth0.disable_ipv6 = 1
Disable IPv6 also by reloading /proc stuff.
$ sudo nano /etc/rc.local # Add this right above the `exit 0` /etc/init.d/procps force-reload
You can test this works like this, and the latter command should not return anything.
sudo sh /etc/rc.local ifconfig | grep inet6.
-
Update the Raspberry Pi to use fixed IP address by editing DHCP configuration:
sudo nano /etc/dhcpcd.conf
Look for section "# Example static IP configuration" and read through. You probably need to add something like this at the end of the file:
interface wlan0 static ip_address=192.168.1.5/24 static routers=192.168.1.1 static domain_name_servers=192.168.1.1
interface
iswlan0
for wifi, andeth0
for wired connection.
ip_address
is your fixed IP address (and keep the/24
- it means all IPs192.168.1.*
are local).
routers
is your DCHP server, which is usually also the wifi router.
domain_name_servers
is most likely the same as your routers IP address. Add more by separating additional values with a space (192.168.1.1 4.2.2.4
etc.) I also enabledoption ntp_servers
by removing the hash (#
) from the beginning of the line. -
Login again using the fixed IP address
$ ssh [email protected]
-
Turn off wifi power management (sleep mode)
Add this to file
/etc/network/interfaces
to turn off wifi (wlan0
) power management:allow-hotplug wlan0 iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf wireless-power off
@see: https://community.openhab.org/t/disable-wifi-sleep-mode-on-pi3-and-pi-zero-w/29917, https://www.kuerbis.org/2016/03/raspberry-pi-3-kurztipps-wlan-sleep-mode-verhindern/
You can check if the power management is on or off with either of these two:
$ iwconfig # displays among other things "Power Management:off" $ iw wlan0 get power_save Power save: off # Turn off until the next reboot with $ iw wlan0 set power_save off
-
Update Raspberry Pi hostname
$ sudo nano /etc/hostname homeraspi # update also hosts file to point the new hostname to localhost IP $ sudo nano /etc/hosts # replace old hostname on this line 127.0.1.1 raspberrypi # with your new one 127.0.1.1 homeraspi
You may want to update also your own laptop's /etc/hosts file with this record (add it to the end of the file).
# on your laptop $ sudo nano /etc/hosts 192.168.1.5 yourhomeraspi
-
Don't forget to change the password for
pi
user account!passwd
-
Put your SSH key to Raspberry Pi's
pi
user's accountNow you can login using without your password, which is not just faster to connect to Raspberry Pi but also safer.
First create the
.ssh
folder in Raspberry Pi:mkdir /home/pi/.ssh
Assuming your SSH key is in file
id_rsa.pub
copy it from your laptop to Raspberry Pi:# on your laptop scp ~/.ssh/id_rsa.pub pi@yourhomeraspi:/home/pi/.ssh/ # On Raspberry Pi cd /home/pi/.ssh cat id_rsa.pub > authorized_keys rm id_rsa.pub
-
Update all packages
sudo apt update sudo apt upgrade sudo apt autoremove
-
Reboot Raspberry Pi
sudo reboot
Sources:
- initial Pi setup https://www.youtube.com/watch?v=EeEU_8HG9l0
- fixed IP address setup https://nickcullen.net/blog/raspberry-pi-tutorials/fixed-ip-address-over-ethernet-wifi-raspberry-pi/
- turn off IPv6 https://cwesystems.com/?p=231