Jetson Nano (Ubuntu) Connect to Wifi via Command Line

Jul 29, 2020

Run iwconfig

dlinano@jetson-nano:~$ iwconfigeth0      no wireless extensions.dummy0    no wireless extensions.rndis0    no wireless extensions.usb0      no wireless extensions.l4tbr0    no wireless extensions.lo        no wireless extensions.

Pluck in your Wifi Adapter into the USB port

dlinano@jetson-nano:~$ iwconfigeth0      no wireless extensions.dummy0    no wireless extensions.rndis0    no wireless extensions.usb0      no wireless extensions.wlan0     IEEE 802.11  ESSID:off/any          Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm          Retry short limit:7   RTS thr:off   Fragment thr:off          Power Management:offl4tbr0    no wireless extensions.lo        no wireless extensions.

Scan for available wifi connection

sudo iwlist wlp4s0 scan | grep ESSID

Install wpasupplicant from default software repository (no Internet required)

sudo apt install wpasupplicant

Store wifi name (ESSID) and password into /etc/wpa_supplicant.conf.

wpa_passphrase WIFI_ESSID_NAME WIFI_PASSWORD | sudo tee /etc/wpa_supplicant.conf

Connect to wifi

sudo wpa_supplicant -c /etc/wpa_supplicant.conf -i wlan0

The connection might fail with CTRL-EVENT-DISCONNECTED

Successfully initialized wpa_supplicant
wlan0: SME: Trying to authenticate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)
wlan0: Trying to associate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)
wlan0: Associated with c0:25:e9:ec:44:db
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: CTRL-EVENT-DISCONNECTED bssid=c0:25:e9:ec:44:db reason=3 locally_generated=1
wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
wlan0: CTRL-EVENT-REGDOM-CHANGE init=BEACON_HINT type=UNKNOWN
wlan0: SME: Trying to authenticate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)
wlan0: Trying to associate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)
wlan0: Associated with c0:25:e9:ec:44:db
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: CTRL-EVENT-DISCONNECTED bssid=c0:25:e9:ec:44:db reason=3 locally_generated=1
wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
wlan0: CTRL-EVENT-REGDOM-CHANGE init=BEACON_HINT type=UNKNOWN
wlan0: SME: Trying to authenticate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)
wlan0: Trying to associate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)
wlan0: Associated with c0:25:e9:ec:44:db
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: CTRL-EVENT-DISCONNECTED bssid=c0:25:e9:ec:44:db reason=3 locally_generated=1
wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
wlan0: CTRL-EVENT-REGDOM-CHANGE init=BEACON_HINT type=UNKNOWN
wlan0: SME: Trying to authenticate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)
wlan0: Trying to associate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)
wlan0: Associated with c0:25:e9:ec:44:db
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: CTRL-EVENT-DISCONNECTED bssid=c0:25:e9:ec:44:db reason=3 locally_generated=1
wlan0: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="totoro3@unifi" auth_failures=1 duration=10 reason=WRONG_KEY
wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="totoro3@unifi" auth_failures=2 duration=23 reason=CONN_FAILED
wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
wlan0: CTRL-EVENT-REGDOM-CHANGE init=BEACON_HINT type=UNKNOWN
wlan0: CTRL-EVENT-SSID-REENABLED id=0 ssid="totoro3@unifi"
wlan0: SME: Trying to authenticate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)
wlan0: Trying to associate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)
wlan0: Associated with c0:25:e9:ec:44:db
wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
wlan0: CTRL-EVENT-DISCONNECTED bssid=c0:25:e9:ec:44:db reason=3 locally_generated=1
wlan0: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="totoro3@unifi" auth_failures=3 duration=46 reason=WRONG_KEY
wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="totoro3@unifi" auth_failures=4 duration=77 reason=CONN_FAILED
wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
wlan0: CTRL-EVENT-REGDOM-CHANGE init=BEACON_HINT type=UNKNOWN

You might need to disable NetworkManager

sudo systemctl stop NetworkManager

NOTE: Optional to disable NetworkManager to auto-start during bootup sudo systemctl disable NetworkManager-wait-online NetworkManager-dispatcher NetworkManager

Try again. Should see CTRL-EVENT-CONNECTED upon success.

sudo wpa_supplicant -c /etc/wpa_supplicant.conf -i wlan0wlan0: CTRL-EVENT-REGDOM-CHANGE init=BEACON_HINT type=UNKNOWNwlan0: SME: Trying to authenticate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)wlan0: Trying to associate with c0:25:e9:ec:44:db (SSID='totoro3@unifi' freq=2462 MHz)wlan0: Associated with c0:25:e9:ec:44:dbwlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0wlan0: WPA: Key negotiation completed with c0:25:e9:ec:44:db [PTK=CCMP GTK=CCMP]wlan0: CTRL-EVENT-CONNECTED - Connection to c0:25:e9:ec:44:db completed [id=0 id_str=]

wpa_supplicant run in the foreground by default, press CTRL-C to stop it.

Now run wpa_supplicant in the background.

sudo wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlan0

Get IP address via DHCP

sudo dhclient wlan0cmp: EOF on /tmp/tmp.ZAVph8f1KE which is empty

NOTE: To relase ip address sudo dhclient wlan0 -r

Show IP address

dlinano@jetson-nano:~$ ip addr show wlan07: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000    link/ether f4:f2:6d:XX:XX:XX brd ff:ff:ff:ff:ff:ff    inet 192.168.0.199/24 brd 192.168.0.255 scope global wlan0       valid_lft forever preferred_lft forever    inet6 2001:e68:542c:1838:18a4:b405:1fd3:4335/64 scope global temporary dynamic       valid_lft 86352sec preferred_lft 14352sec    inet6 2001:e68:542c:1838:f6f2:6dff:fe12:ac3f/64 scope global dynamic mngtmpaddr       valid_lft 86352sec preferred_lft 14352sec    inet6 fe80::f6f2:6dff:fe12:ac3f/64 scope link       valid_lft forever preferred_lft forever

Test if Internet is accessible

ping 8.8.8.8

NOTE: For auto connect at bootup, refer to https://www.linuxbabe.com/ubuntu/connect-to-wi-fi-from-terminal-on-ubuntu-18-04-19-04-with-wpa-supplicant

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.