RPi Wi-Fi password change

I’ve prepared my work environment on RPi Zero at my home with stable and static Wi-Fi. So all my development process rely on work over SSH. Now I’m not at home, and beeing in hurry, forgot to:

  1. Apply RPi Zero new Wi-Fi settings.
  2. Get Keyboard and display with me (to be able to connect to RPi and update its network settings).

As result I have my laptop with me, my RPi Zero, but it can’t connect to new Wi-Fi network.

Need to deal with it.

Connect Somewhere Somehow

Since I know my home Wi-Fi network SSID, password etc, I can re-create this network on my Android phone.

Create it, start, suppose to get connected.

By the way, I’ve connected laptop to the same “mobile’s” network, so all commands were executed from laptop (I feel myself a bit lazy, but also it’s comfy).

Find RPi in the same network

Thanks, that on Raspbian, multicast DNS is supported out-of-the-box by the Avahi service. See more on this on official RPi help. This point simplify life a lot. Otherwise one just need to scan network using nmap (Article on “Notes on Linux”).

So we could just do:

$ ping raspberrypi.local
PING raspberrypi.local (192.168.43.98) 56(84) bytes of data.
64 bytes from raspberrypi (192.168.43.98): icmp_seq=1 ttl=64 time=9.75 ms
64 bytes from raspberrypi (192.168.43.98): icmp_seq=2 ttl=64 time=6.43 ms
^C
--- raspberrypi.local ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 6.430/8.092/9.754/1.662 ms

Got it! My RPi is in the same network, under this IP: 192.168.43.98.

Doing SSH into it.

$ ssh pi@raspberrypi.local
pi@raspberrypi.local's password:
Linux raspberrypi 4.14.34+ #1110 Mon Apr 16 14:51:42 BST 2018 armv6l

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: Fri Apr 27 19:31:02 2018 from 192.168.0.111
pi@raspberrypi:~ $

Perfect!

We are in

To get RPi acquainted with new network I need to edit /etc/wpa_supplicant/wpa_supplicant.conf according to official help

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=UA

network={
        ssid="Just_do_it"
        psk="PASSWORD_TO_MY_HOME_NETWORK"
}

network={
        ssid="dom"
        psk="PASSWORD_TO_NEW_NETWORK"
}

As you can see I’ve appended information about my new network into this file, and its password. To be more secure, you can use encrypted PSK:

wpa_passphrase "ssid of your network" "password of your network"h >> /etc/wpa_supplicant/wpa_supplicant.conf

Note: wpa_passphrase result is generated text:

network={
    ssid="ssid of your network"
    #psk="password of your network"
    psk=5adf0a3d0d1f237a84b342e5c383e4e1fa0b7e5b43e95375dfe209a68ad92c3d
}

Do not forgot to be root to be able to append it to /etc/wpa_supplicant/wpa_supplicant.conf.

Final notes

Shutdown RPi: sudo shutdown. No more need of “mobile’s” network – turn it off.

Now I’m able to turn on my RPi and see it inside my new network! DONE.

Good luck to anyone who is stepping behind be 🙂

comments powered by Disqus